News for hackers. Stuff that matters.
Re:Announcing TypeScript 3.9 by shroom on Wednesday May 13, 2020 @10:03AM (#23166960)
Oh thanks! Yes my "problem" is mostly around what types to return or rather how to find them. To be aware that separate types package must be installed is definitely something to get into habit.

I wasn't aware of the `.d.ts` files. It sounds a lot like what I was looking for! Thanks again for your feedback and help :-)

Re:Announcing TypeScript 3.9 by bavell on Wednesday May 13, 2020 @11:57AM (#23168208)
Most of the time you can just `npm install -D @types/package-name` to get the types for that package. E.g. `npm i -D @types/lodash`
Re:Announcing TypeScript 3.9 by WorldMaker on Wednesday May 13, 2020 @05:32PM (#23172076)
I find you generally want the @types/ dependencies in the same package.json array as the related dependency (ie, if lodash is a devDependency then `npm i -D` away, but if it is a proper dependency it generally makes sense to `npm i @types/lodash`). Different project's mileage will of course vary, but it makes it easier for downstream dependencies.
Re:Announcing TypeScript 3.9 by strogonoff on Wednesday May 13, 2020 @12:20PM (#23168498)
As to the remaining cases, a custom definitions file is unfortunately required to avoid compile-time errors.
Re:Announcing TypeScript 3.9 by strogonoff on Wednesday May 13, 2020 @11:10AM (#23167608)
If finding types is especially difficult, it may depend on a particular library (poorly documented types) and on the tooling you use (e.g., VS Code allows to quickly jump to definition/implementation/etc. on any imported class or component in your code, which often takes you to the place in that library where you can find out which types you need and where to import them from; it was a bigger pain in Vim).

By the way, keep in mind that it is often unnecessary to specify types explicitly because TS can infer them from context. I used to specify way too many types when I was initially learning TS.