Skip to content

Commit d3f34b5

Browse files
committed
Update README.md
1 parent 4caa90d commit d3f34b5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

packages/core-js-types/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
![logo](https://user-images.githubusercontent.com/2213682/146607186-8e13ddef-26a4-4ebf-befd-5aac9d77c090.png)
22
This package contains types for global & pure versions of `core-js`.
3+
Although `core-js` is a polyfill library for the JavaScript, the built-in TypeScript types are not sufficient.
4+
Additional types are needed for:
5+
- features that are already in JavaScript, but not yet in TypeScript’s standard types;
6+
- proposals, including those already implemented in JavaScript engines;
7+
- explicit imports of features from the pure version.
8+
9+
We decided to ship it as a separate package, because we cannot guarantee stable behavior,
10+
primarily with upcoming minor TypeScript releases
311

412
# Installation
513
`npm install --save @core-js/[email protected]`
@@ -19,6 +27,7 @@ or import it directly in your files:
1927
```ts
2028
import '@core-js/types';
2129
```
30+
`@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 instead.
2231

2332
## Usage of subsets
2433
There are 4 types of subset:
@@ -61,7 +70,8 @@ $findLast([1, 3, 4, 2], v => v > 2); // => 4
6170
```
6271

6372
## Namespace usage
64-
If you need to use multiple methods from the same namespace, you can import the entire namespace instead:
73+
If you need to use multiple methods from the same namespace, you can add `@core-js/types/pure` to `tsconfig.json`
74+
and import the entire namespace instead:
6575
```ts
6676
import $array from '@core-js/pure/full/array';
6777

@@ -70,17 +80,13 @@ $array.flatMap([1, 2, 3], x => [x, x * 2]);
7080
```
7181

7282
# DOM types
73-
Global types works correctly only with DOM lib. You need to add DOM types to the `lib` section of your `tsconfig.json`, for example:
83+
A part of the global types for web standards work correctly only with the DOM lib.
84+
You need to add DOM types to the `lib` section of your `tsconfig.json`, for example:
7485
```json
7586
{
7687
"compilerOptions": {
7788
"lib": ["esnext", "dom"]
7889
}
7990
}
8091
```
81-
In `pure` version you can use it without adding additional DOM types:
82-
```ts
83-
import $parse from '@core-js/pure/full/url/parse';
84-
85-
$parse('https://example.com/path?name=value#hash');
86-
```
92+
In the `pure` version you can use it without adding DOM lib

0 commit comments

Comments
 (0)