What if you never had to write complex type definitions for popular libraries again?
Why DefinitelyTyped and @types packages in Typescript? - Purpose & Use Cases
Imagine you want to use a popular JavaScript library in your TypeScript project, but it has no built-in type information. You try to write your own type definitions manually for every function and object it offers.
Writing type definitions by hand is slow and tricky. You might miss some details or make mistakes, causing errors later. Every time the library updates, you must update your types too, which is frustrating and error-prone.
DefinitelyTyped and @types packages provide ready-made, community-maintained type definitions for thousands of JavaScript libraries. You just install them, and TypeScript understands the library perfectly without extra work.
declare function doSomething(x: any): any; // manual and vague type
// ... lots of manual type declarationsnpm install --save-dev @types/library-name
// TypeScript automatically uses detailed types from @types/library-nameYou can confidently use many JavaScript libraries in TypeScript with accurate type checking and autocompletion, saving time and avoiding bugs.
When adding lodash to your TypeScript project, installing @types/lodash gives you instant access to all lodash functions with correct types, so you never guess parameter types or return values.
Manual type writing is slow and error-prone.
DefinitelyTyped offers community-made type definitions.
@types packages let TypeScript understand JavaScript libraries easily.