Skip to content

Commit f379e0a

Browse files
slowcheetahzloirock
authored andcommitted
Update README.md and TypeScript type definitions doc
1 parent 0807460 commit f379e0a

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

docs/web/docs/typescript-type-definitions.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,27 @@ npm install --save @core-js/types@4.0.0-alpha.0
1515
```
1616

1717
## Usage
18-
Add to your `tsconfig.json`:
18+
You must include at least the ES6 types in your `tsconfig.json` because our types are built on top of the ES6 type definitions
19+
and `DOM` lib for the global version if you use something related (see [DOM types](#dom-types) section):
1920
```json
2021
{
2122
"compilerOptions": {
23+
"lib": [
24+
"es6",
25+
"dom"
26+
],
2227
"types": [
2328
"@core-js/types"
2429
]
2530
}
2631
}
2732
```
28-
or import it directly in your files:
33+
34+
You can also import the types directly into your files instead of specifying `core-js` types in your `tsconfig.json`:
2935
```ts
3036
import '@core-js/types';
3137
```
38+
3239
`@core-js/types` includes all types and entry points for the global version, but it is recommended to select only the subset you actually use.
3340

3441
### Usage of subsets
@@ -70,14 +77,17 @@ or import them directly in your files:
7077
import '@core-js/types/proposals/joint-iteration';
7178
import '@core-js/types/web/structured-clone';
7279
```
73-
You can find types for specific features on the corresponding pages in the [documentation](https://core-js.io/{docs-version}/docs/).
80+
You can find types for specific features on the corresponding pages in the [documentation](https://core-js.io/v4/docs/).
7481

7582
## Types for the pure version
7683
### Base usage
77-
Add this to your `tsconfig.json`:
84+
Add this to your `tsconfig.json`, keeping in mind that ES types (at least ES6) are required:
7885
```json
7986
{
8087
"compilerOptions": {
88+
"lib": [
89+
"es6"
90+
],
8191
"types": [
8292
"@core-js/types/pure"
8393
]
@@ -107,8 +117,13 @@ You need to add DOM types to the `lib` section of your `tsconfig.json` in additi
107117
```json
108118
{
109119
"compilerOptions": {
110-
"types": ["@core-js/types"],
111-
"lib": ["esnext", "dom"]
120+
"types": [
121+
"@core-js/types"
122+
],
123+
"lib": [
124+
"esnext",
125+
"dom"
126+
]
112127
}
113128
}
114129
```

packages/core-js-types/README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,27 @@ npm install --save @core-js/types@4.0.0-alpha.0
1515
```
1616

1717
# Usage
18-
Add to your `tsconfig.json`:
18+
You must include at least the ES6 types in your `tsconfig.json` because our types are built on top of the ES6 type definitions
19+
and `DOM` lib for the global version if you use something related (see [DOM types](#dom-types) section):
1920
```json
2021
{
2122
"compilerOptions": {
23+
"lib": [
24+
"es6",
25+
"dom"
26+
],
2227
"types": [
2328
"@core-js/types"
2429
]
2530
}
2631
}
2732
```
28-
or import it directly in your files:
33+
34+
You can also import the types directly into your files instead of specifying `core-js` types in your `tsconfig.json`:
2935
```ts
3036
import '@core-js/types';
3137
```
38+
3239
`@core-js/types` includes all types and entry points for the global version, but it is recommended to select only the subset you actually use.
3340

3441
## Usage of subsets
@@ -74,10 +81,13 @@ You can find types for specific features on the corresponding pages in the [docu
7481

7582
# Types for the pure version
7683
## Base usage
77-
Add this to your `tsconfig.json`:
84+
Add this to your `tsconfig.json`, keeping in mind that ES types (at least ES6) are required:
7885
```json
7986
{
8087
"compilerOptions": {
88+
"lib": [
89+
"es6"
90+
],
8191
"types": [
8292
"@core-js/types/pure"
8393
]
@@ -107,8 +117,13 @@ You need to add DOM types to the `lib` section of your `tsconfig.json` in additi
107117
```json
108118
{
109119
"compilerOptions": {
110-
"types": ["@core-js/types"],
111-
"lib": ["esnext", "dom"]
120+
"types": [
121+
"@core-js/types"
122+
],
123+
"lib": [
124+
"esnext",
125+
"dom"
126+
]
112127
}
113128
}
114129
```

0 commit comments

Comments
 (0)