Search code examples
typescriptdefinitelytypedtypescript-definitions

Distribution of TypeScript definiton files


I have used TypeScript since the beginning and have gone through the iterations of tools and repositories for getting TypeScript definition files (i.e, somelib.d.ts) for Third Party libraries - definitelytyped, tsd, typings, nuget, and now the npm @types repository and developers including the types in their packages.

My question is today, what is the ideal way for distributing a definition file?

I get that if a developer is unwilling to provide typescript files, another developer could then submit those to the definitelytyped project so they are available.

If a developer is willing to accept a Pull Request, is it better to have them distributed with the package?

If a definition file is included with a package, is there a standard for including them (folder/name)?


Solution

  • The ideal way is definitely to ship typings alongside the actual code. This makes the story very easy for package consumers to get started with Typescript without any extra steps.

    Bundling types with the core code package, rather than through DefinitelyTyped, is also what is recommended by the TypeScript docs.

    In terms of "standard for including them", all you really need to do is make sure that the types or typings field in package.json is filled with the path to your typings.