I have been using typescript for a little while in node.js projects. I understand that for many npm packages there is separate @types package for typescript type definitions.
My question is: how can I know that the @types package is up to date with the latest version of the actual package when they are maintained separately?
For example there is npm package better-sqlite3 with no typescript definitions and then a separate type definition package @types/better-sqlite3. How user of the package can know that types match the current version of the package?
In this answer here it is said that "TypeScript types for JS packages is best effort and depends on Community interest in the package". This sounds a bit scary.
CodePudding user response:
The types package shouldn't be maintained separately. The author of the package should be listing the corresponding types package as a dependency
which means the correct version of the typing should come along when you install the top-level package.
REF: https://github.com/Microsoft/types-publisher/issues/81
CodePudding user response:
If the package developers maintain the definitions themselves, there's no
@types
,d.ts
s are just building in package distroIf there's
@types
, you may check the last update date of both packages (@types
haveLast updated
in readme), the@types
probably was correct at the time when it was last updated.If the
@types
is outdated, you may update if yourself and even publish on@types
, that's what "TypeScript types for JS packages is best effort and depends on Community interest in the package" means