I'm using a lot of implicit any in TypeScript. I don't quite understand how to decipher a TSD file in order to get the correct type when building off a library like express or angular. Is there a way to learn what the type of something is at runtime, so that I can go back and fill in the type later? Or is there another way of figuring out types based on existing code?
Is there a way to learn what the type of something is at runtime, so that I can go back and fill in the type later?
TypeScript uses type erasure and does not run at runtime:
Use an alternative, such as the following:
typeof 1; /foo/ instanceof RegExp Error.isPrototypeOf(ReferenceError) this.constructor Object.getPrototypeOf(NaN)
As mentioned previously TS has model of the types only compile time. If you open the produced js files you'll get good understanding what's "left" and visible at runtime.
Your struggle seems to originate in the problem that you are using libraries whithout being able to know the types their methods return or expect, that's what I undrestand. Which IDE or editor are you using? VSCode or Atom (or even Emacs) have excellent intellisense for typescipt.
The tsd files are bit confusing and importing types is bit of a magic for me yet, but just reading the raw libfefs still could provide you with enough understanding about the most frequent types.