4
votes

According to https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/:

DefinitelyTyped will still be the place to author new declaration files.

But it's unclear why we'd create new definitions at DefinitelyTyped as opposed to submitting them directly to NPM.

Being that DT is so large now, it seems counter productive to continue adding to that repo. What are the advantages of DT over publishing to NPM directly?

2
What does 'submitting them directly to NPM' mean to you?Paarth
I was considering creating a github repo for the definition (it's for a third party js library that doesn't have their own definition), along with with all the requisite files for supporting NPM. I'd then publish it as a new NPM package under @types.Alex Dresko
Can you even publish to the @types org without going through DefinitelyTyped?Paarth

2 Answers

6
votes

The DefinitelyTyped repo is being treated as the endorsed community repository of type declarations for packages that don't provide their own.

Answering this question depends on what you mean when you say

submitting them directly to NPM.

If you mean including the .d.ts file with the package that the .d.ts file corresponds to that's encouraged. The moment package, for example, includes and maintains its own declaration file.

If you mean providing your own type only package then DefinitelyTyped is the better location for those files and will provide some advantages. By including your file in DefinitelyTyped it will

  • benefit from automated deploys to the @types namespace by the TS typings bot.
    • which will also yield predictable module resolution in the compiler.
  • be in the long established source for typings. You'll be where people are looking.
  • be more easily maintained by others.
    • the package will be easier to find
    • maintainers will use a workflow and format they're familiar with
3
votes

To add to Paarth's answer, being in DefinitelyTyped provides extra benefits you should consider:

  • Automatic version tags for older TypeScript language versions. If you ship your definition file in your own package, then you and your consumers have to agree on which version of TypeScript to use. If it's on DefinitelyTyped, as you update the definition file, the @types publisher will automatically tag the latest compatible release for older TS versions (e.g. people on TS 2.1 can npm install @types/[email protected] to get a 2.1-compatible version)
  • Free maintenance from the DefinitelyTyped maintainers. Often DT can find definition file bugs by writing new TSLint rules and applying them across the entire codebase
  • Better versioning - you can more easily provide side-by-side definitions for multiple versions of your library, and version these independently of the underlying library