TypeScript
Declarations Commands
Generate and manage .d.ts declaration files for TypeScript libraries. Create type definitions, use DefinitelyTyped, and publish type-safe packages.
4 commands
Pro Tips
Generate declarations: 'tsc --declaration --emitDeclarationOnly' creates .d.ts files without JavaScript.
Install community types: 'npm install -D @types/node @types/react' for packages without built-in types.
Create a global.d.ts for ambient declarations like module augmentation and global type overrides.
Common Mistakes
Don't install @types/* packages that the library already bundles. Check if 'types' field exists in the package's package.json.
@types/* version should match the library version. Mismatched versions cause confusing type errors.