Skip to content

Commit 658a4e6

Browse files
committed
Type definitions contributing skeleton
1 parent f2fbacf commit 658a4e6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ engine | how to run tests | base data inherits from | mandatory ch
6565

6666
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/).
6767

68+
## How to add new TypeScript 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
89+
```
90+
6891
## Style and standards
6992

7093
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

Comments
 (0)