core-js
core-js copied to clipboard
feat: migrate to TypeScript and ESM
TypeScript
I think it might be possible to make this change in v4, and here are some reasons why:
- Increase readability and lower the threshold for contribution (it's a bit too difficult to contribute now)
- Can generate declaration files directly instead of maintaining dts manually
I think this change would reduce your maintenance burden in the long run
ESM
Maybe we can write the code in ESM and then use a tool like esbuild to bundle the esm into cjs and iife while compiling the TypeScript
Migration to ESM is planned.
Migration to TypeScript is a controversial question. I'm not a big fan of TypeScript. In some internal cases, it could cause some problems. Anyway, I think this needs to be thought about.
However, adding TypeScript definitions is required and planned since the usage of core-js
(proposals, pure version, tooling) without it in TypeScript is problematic. Adding it to tooling is already started - #1163, #1235.
Considering the positive effects, I think it might be worth it 😄
Also, has https://github.com/zloirock/core-js/pull/1221 been abandoned? You haven't replied for a long time 😓
@DreamOfIce It's not abandoned. Sorry. After some events and burnout, I decided to take a little vacation with my family, so I spent less time than usual on the project. I'll take care of this PR soon.
However, adding TypeScript definitions is required and planned since the usage of core-js (proposals, pure version, tooling) without it in TypeScript is problematic.
I have converted all type declarations to typescript in #1221 and checked them against the source code and the official TypeScript declaration file. Maybe we can write them to a separate file for use.
@DreamOfIce Perhaps TS types can be provided via JSDoc as a first step instead of attempting to maintain declaration files separately. This will allow for generation of declaration files and also provide types in supported tooling even without that step. Additionally, it will make it easier to refactor to TS in the future (if that's desired) because the types will be colocated in comments with the implementation code.
Perhaps TS types can be provided via JSDoc as a first step instead of attempting to maintain declaration files separately.
But we have maintained a type declaration (non-standard TS syntax) for the docs. And converted to standard typescript by me in #1221.
BTW, it is a good idea to add some comments using JSDoc In fact the new type declaration has some JSDoc comments mixed in, e.g: https://github.com/DreamOfIce/core-js/blob/afe5b233ed91ee9311be6e397c353bd4de8680ff/docs/features/es-standard/number.md?plain=1#L57-L58