Gary Sieling

TypeScript import example

In Typescript “imports” are called “references”.

If you have a type definition file (.d.ts) you can import it directly with a comment:

/// 

I think most people at the moment are moving to a tool called “typings”, which helps you find an manage local copes of these files for your libraries.

The type definition files feel a little kludgey, but they really are equivalent to .h (header) files in C, basically you’re defining that something exists, but the actual call will be handled post-compilation: at runtime, in the case of Javascript, rather than using a linker, in C.

Because of this property, Typescript tends to try to generate Javascript code if it can, even if it thinks you’re doing something that is a bad idea. I’ve so far found a lot of minor defects because of it’s enforcement, although pretty much any error has been a warning.

Exit mobile version