3 ms·
Does TS really require type files for every JS library you use? I tried to use it the other day with node.js but couldn't find a type file for the popular simp
by WhitneyLand 11y ago
Does TS really require type files for every JS library you use?
I tried to use it the other day with node.js but couldn't find a type file for the popular simple-oauth2 package.
- spion 11y agoYou can say that the library is of "any" type and the compiler will accept all method calls on it. However it should be fairly easy to write a .d.ts file for it. You don't even have to cover the entire library - its enough to specify the types of the parts you use.
- tlarkworthy 11y agohttps://github.com/borisyankov/DefinitelyTyped https://github.com/borisyankov/DefinitelyTyped and TSD to copy into your directory from DT (it's like a package manager for definitions). Not ideal but that's the practice. Doesn't cover your simple-oauth2 example though, but its not that bad adding the individual methods you need on demand (easier if you have the definatelyTyped examples to follow).
- Nitramp 11y agoYes, but that's a good thing. .d.ts files are reasonably straightforward to write (the external vs internal module thing is the exception), and easy to share on DefinitelyTyped. But that only happened because TypeScript requires .d.ts files - the requirement pushes the community forward, with benefits for all.