You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ There is always some ["help wanted" issues](https://github.com/zloirock/core-js/
16
16
- For export the polyfill, in all common cases use [`internals/export`](./packages/core-js/modules/export.js) helper. Use something else only if this helper is not applicable - for example, if you want to polyfill accessors.
17
17
- If the code of the pure version implementation should significantly differ from the global version (*that's not a frequent situation, in most cases [`internals/is-pure`](./packages/core-js/modules/is-pure.js) constant is enough*), you can add it to [`packages/core-js-pure/override`](./packages/core-js-pure/override) directory. The rest parts of `@core-js/pure` will be copied from `core-js` package.
18
18
- Add the feature detection of the polyfill to [`tests/compat/tests.js`](./tests/compat/tests.js), add the compatibility data to [`packages/core-js-compat/src/data.mjs`](./packages/core-js-compat/src/data.mjs), how to do it [see below](#how-to-update-core-js-compat-data).
19
-
- Add it to entries definitions, see [`scripts/build-entries/entries-definitions.mjs`](./scripts/build-entries/entries-definitions.mjs).
19
+
- Add it to entries definitions, see [`scripts/build-entries-and-types/entries-definitions.mjs`](scripts/build-entries-and-types/entries-definitions.mjs).
20
20
- Add unit tests to [`tests/unit-global`](./tests/unit-global) and [`tests/unit-pure`](./tests/unit-pure).
21
21
- Add tests of entry points to [`tests/entries/unit.mjs`](./tests/entries/unit.mjs).
22
22
- Make sure that you are following [our coding style](#style-and-standards) and [all tests](#testing) are passed.
@@ -65,6 +65,33 @@ engine | how to run tests | base data inherits from | mandatory ch
65
65
66
66
If you have no access to all required browsers / versions of browsers, use [Sauce Labs](https://saucelabs.com/), [BrowserStack](https://www.browserstack.com/) or [Cloud Browser](https://ieonchrome.com/).
67
67
68
+
## TypeScript type definitions
69
+
70
+
- TypeScript definitions should be added to the [`packages/core-js-types/src/base`](./packages/core-js-types/src/base) directory.
71
+
- Our type definitions are built on top of ES6. If any related type is missing in ES6, it must be added to the [`packages/core-js-types/src/base/core-js-types`](./packages/core-js-types/src/base/core-js-types) directory and imported via triple-slash directives in your type definition file.
72
+
- Place your type definition into the folder that matches its kind ([`packages/core-js-types/src/base/proposals`](./packages/core-js-types/src/base/proposals), [`packages/core-js-types/src/base/web`](./packages/core-js-types/src/base/web)).
73
+
- Type definitions for the pure version are either generated from the global version types or created manually in the [`packages/core-js-types/src/base/pure`](./packages/core-js-types/src/base/pure) folder. Type build rules for the pure version can be modified using the `@type-options` directive:
74
+
-`no-extends` – do not extend the base type when adding a prefix to the type/interface
75
+
-`no-prefix` – do not add a prefix to the type/interface name
76
+
-`no-constructor` – use it when the type has no constructor (for example, `Math`)
77
+
-`export-base-constructor` – export the base type’s constructor instead of the prefixed one
78
+
-`no-export` – do not export this type
79
+
-`no-redefine` – do not redefine the type’s constructor
80
+
-`prefix-return-type` – add a prefix to the return type
81
+
- All type definitions must be covered by TSC tests. Add them to the [`tests/type-definitions`](./tests/type-definitions) directory.
82
+
- To build the types, run the command:
83
+
```sh
84
+
npm run build-types
85
+
```
86
+
- To test the types, run the command:
87
+
```sh
88
+
npm run test-type-definitions-all
89
+
```
90
+
- To run the fast subset of the types test, run the command:
91
+
```sh
92
+
npm run test-type-definitions-smoke
93
+
```
94
+
68
95
## Style and standards
69
96
70
97
The coding style should follow our [`eslint.config.js`](./tests/eslint/eslint.config.js). You can test it by calling [`npm run lint`](#testing). Different places have different syntax and standard library limitations:
0 commit comments