jonschlinkert / is-primitive

Is the typeof value a javascript primitive?
MIT License
37 stars 9 forks source link

TypeScript type declaration file #9

Open geopic opened 4 years ago

geopic commented 4 years ago

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.

ljharb commented 4 years ago

That’s what DefinitelyTyped is for.

geopic commented 4 years ago

I'm just proposing another option @ljharb.

ljharb commented 4 years ago

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.

geopic commented 4 years ago

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.

ljharb commented 4 years ago

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.