Skip to main content

DefinitelyTyped

DefinitelyTyped is the most common repository of Declaration Files for numerous JavaScript libraries, the majority of which do not provide their own (as they are not developed with TypeScript and are not committed to work with it). As a result, it houses community-maintained Declaration files.

You can use most of the common JavaScript libraries as if they were TypeScript libraries by utilising DefinitelyTyped and the declaration files it contains. You'll get type validation from the compiler (as the declaration file indicates). DefinitelyTyped will also be maintained by the community to contain valid declaration files due to its popularity (although, web development being something that moves really fast, you may end up finding a couple of issues specially in obscure libraries).

We all know how popular Lodash is. Many other people have expressed interest in the types in this library. In a community-sourced repository of type definition files, DefinitelyTyped. There's a strong possibility someone else has previously written a type definition file for the JavaScript library you're wanting to utilise in your TypeScript code.

One thing to remember is that the type definition files in DefinitelyTyped are community sourced. In most cases they are not written by the library authors. There will be missing and/or incorrect definitions in some of these files. When you find that patch and send them a PR. We will look at how to fix these temporarily in a minute. However, please contribute back when you can.

DefinitelyTyped is the most common source of declaration files for various JavaScript libraries, the majority of which do not supply their own declaration files (because they are not developed with TypeScript and do not promise to use it). As a result, it preserves the community-maintained declaration file.

You can use most popular JavaScript libraries as if they were TypeScript libraries by utilising DefinitelyTyped and its accompanying declaration files, and the compiler will type-verify your code (as shown in the declaration file).Furthermore, because DefinitelyTyped is so popular, the community will filter it to contain legitimate declaration files (although, web development moves very fast, and you may end up finding some problems in unobvious libraries).

Publishing

Before we begin, I'm assuming you've run into one of the following scenarios:

  • The @type that you want to add is not present in DefTyped types and libraries.
  • Typings that are already in use should be updated.
  • You should remove the DefinitelyTyped definition from the package's definition.

Make a pull request

You can share your package on Definitely Typed once you've tested it.

To get started, fork this repository, clone it, install node, and then run npm install. If you're using npm v7, you'll need to use the —legacy-peer-deps flag.

We employ a bot to allow a huge number of pull requests to be handled totally in a self-service way on DefinitelyTyped. More information on why and how may be found here. Here's a quick reference to the life-cycle of a DT pull request: