Typescript types for code that is not imported by typescript? Typescript types for code that is not imported by typescript? typescript typescript

Typescript types for code that is not imported by typescript?


I had the same problem in the past, and I also find it impossible to import the Type Definition files using import without importing the actual module.

So, what I did is, I copied the Type Definition file (usually index.d.ts) into my codebase.

After that, you could do something like:

import {SomeType} from "sometype.d.ts"declare let ObjectImportedFromHTMLScriptTag: SomeType;

Then, you could use the imported object without breaking type safety.


The answer to my question appears to be here: @types/googlemaps/index.d.ts' is not a moduleThat is, I can use a triple slash directive, or declare the module in a root typings.d.ts file.