16 ms·
Probably 90% of third party libraries I ever used in my TypeScript projects have TypeScript interfaces built into them, so you just install the package like nor
by sbjs 8y ago
Probably 90% of third party libraries I ever used in my TypeScript projects have TypeScript interfaces built into them, so you just install the package like normal `npm i -P somelib`, and TypeScript automatically knows its types. Maybe 9% of them don't, and you have to add types like `npm i -D @types/somelib`. And the other 1% you can add manually yourself by adding them into `global.d.ts` in your project and only creating types for the functions you actually use. I only ever had to do this once, and it took about an hour total. It would have been more like 5 minutes if I had known that you can use the `typeof` operator in TS to specify that a given field is a constructor of another type.