Open geopic opened 4 years ago
That’s what DefinitelyTyped is for.
I'm just proposing another option @ljharb.
Do DT types exist already?
It makes no sense to have a type definition if the project isn’t written in TS, since there’s no reliable way to enforce that the TS type matches the JS file.
It makes no sense to have a type definition if the project isn’t written in TS, since there’s no reliable way to enforce that the TS type matches the JS file.
Both approaches (having a definition file in the repo vs. having a file at @types/is-primitive
) require maintaining. The purpose of a types definition file is to provide types for a library written in JS. Typing a project written in TS which compiles to JS is easier, but most npm packages don't follow that route. In my view it's better to have the definition file as part of the repo as it makes for easier maintainability compared to it being in a different repo, as well as there being less clutter in package.json
.
I very much don't agree; if there's no way to enforce keeping them in sync in-repo, the main npm package might release v1.2.3 with a type bug, and be forced to release a v1.2.4 with no actual JS-related changes. Separating them frees the two conceptually different products to be released independently.
If you want I can write a TypeScript type declaration file for this package so that TS developers can utilise the type-checking feature of the language as they use this package. Let me know if you are interested.