What means “ambient” in TypeScript

The english word

Ambience : the character and atmosphere of a place..

TypeScript version

TypeScript declaration files exist to tell the compiler of the environment in which it is running. Hence the word ambient context. You can only do declarations in a declaration context and not implementations.

E.g. if you have some awesomeLibrary declared in a raw JS file that TypeScript does not know about the following will error:

awesomeLibrary = 123; // Error: `awesomeLibrary` is not defined

So you can declare it in an ambient context and now TypeScript will be fine:

declare var awesomeLibrary: any;
awesomeLibrary = 123; // allowed

More

More on ambient declarations.

Leave a Comment