The repository for high quality TypeScript type definitions.
You can also read this README in Español, 한국어, Русский, 简体中文, Português, Italiano, 日本語 and Français!
Link to Admin manual
Definitely Typed has recently changed to a proper pnpm
monorepo; you may want to reread this document for changes to the layout of packages in this repo.
At the very least, you may want to git clean -fdx
the repo (or node ./scripts/clean-node-modules.js
on Windows) to clean up node_modules
and run pnpm install --filter .
to install the workspace root. See further sections for more info on pnpm install
.
This section tracks the health of the repository and publishing process. It may be helpful for contributors experiencing any issues with their PRs and packages.
- Most recent build type-checked/linted cleanly:
- All packages are type-checking/linting cleanly:
- All packages are being published to npm:
- Current infrastructure status updates
If anything here seems wrong or any of the above are failing, please let us know in the Definitely Typed channel on the TypeScript Community Discord server.
See the TypeScript handbook.
This is the preferred method. For example:
npm install --save-dev @types/node
To install typings for a scoped module, remove the @
and add double-underscore after the scope. For example, to install typings for @babel/preset-env
:
npm install --save-dev @types/babel__preset-env
The types should then be automatically included by the compiler.
You may need to add a types
reference if you're not using modules:
/// <reference types="node" />
See more in the handbook.
For an npm package "foo", typings for it will be at "@types/foo".
If your package has typings specified using the types
or typings
key in its package.json
, the npm registry will display that the package has available bindings like so:
If you still can't find the typings, just look for any ".d.ts" files in the package and manually include them with a /// <reference path="" />
.
Definitely Typed only tests packages on versions of TypeScript that are less than 2 years old.
Older versions of TypeScript
@types
packages have tags for versions of TypeScript that they explicitly support, so you can usually get older versions of packages that predate the 2-year window.
For example, if you run npm dist-tags @types/react
, you'll see that TypeScript 2.5 can use types for react@16.0, whereas TypeScript 2.6 and 2.7 can use types for react@16.4:
Tag | Version |
---|---|
latest | 16.9.23 |
ts2.0 | 15.0.1 |
... | ... |
ts2.5 | 16.0.36 |
ts2.6 | 16.4.7 |
ts2.7 | 16.4.7 |
... | ... |
- Manually download from the
master
branch of this repository and place them in your project Typings(use preferred alternatives, typings is deprecated)NuGet(use preferred alternatives, nuget DT type publishing has been turned off)
You may need to add manual references.
Definitely Typed only works because of contributions by users like you!
Before you share your improvement with the world, use the types yourself by creating a typename.d.ts
file in your project and filling out its exports:
declare module "libname" {
// Types inside here
export function helloWorldMessage(): string;
}
You can edit the types directly in node_modules/@types/foo/index.d.ts
to validate your changes, then bring the changes to this repo with the steps below.
Alternatively, you can use module augmentation to extend existing types from the DT module or use the declare module
technique above which will override the version in node_modules
.
Add to your tsconfig.json
:
"baseUrl": "types", "typeRoots": ["types"],