TsSimpleAst

Ambient

Certain nodes in TypeScript can be ambient. For example, all nodes within a definition file are ambient.

Testing if ambient

Use isAmbient():

classDeclaration.isAmbient(); // returns: boolean

This will do several checks to see if it’s an ambient declaration.

declare keyword

You can check for the declare keyword:

classDeclaration.hasDeclareKeyword(); // returns: boolean

Or get the declare keyword if it exists:

classDeclaration.getDeclareKeyword();

Or toggle the declare keyword on and off:

classDeclaration.toggleDeclareKeyword(true);
classDeclaration.toggleDeclareKeyword(false);
classDeclaration.toggleDeclareKeyword(); // toggles between true and false