AmbientDeclaration: declare
AmbientVariableDeclaration declare
AmbientFunctionDeclaration declare
AmbientClassDeclaration declare
AmbientEnumDeclaration declare
AmbientNamespaceDeclaration
12.1.1 Ambient Variable Declarations
An ambient variable declaration introduces a variable in the containing declaration space.
AmbientVariableDeclaration: var
AmbientBindingList ;
let
AmbientBindingList ;
const
AmbientBindingList ;
AmbientBindingList: AmbientBinding AmbientBindingList ,
AmbientBinding
AmbientBinding: BindingIdentifier TypeAnnotationopt
An ambient variable declaration may optionally include a type annotation. If no type annotation is present, the variable is assumed to have type Any.
An ambient variable declaration does not permit an initializer expression to be present.
12.1.2 Ambient Function Declarations
An ambient function declaration introduces a function in the containing declaration space.
Ambient functions may be overloaded by specifying multiple ambient function declarations with the same name, but it is an error to declare multiple overloads that are considered identical (section ) or differ only in their return types.
Ambient function declarations cannot specify a function bodies and do not permit default parameter values.
12.1.3 Ambient Class Declarations
An ambient class declaration declares a class type and a constructor function in the containing declaration space.
AmbientClassDeclaration: class
BindingIdentifier TypeParametersopt ClassHeritage {
AmbientClassBody }
AmbientClassBody: AmbientClassBodyElementsopt
AmbientClassBodyElements: AmbientClassBodyElement AmbientClassBodyElements AmbientClassBodyElement
AmbientClassBodyElement: AmbientConstructorDeclaration AmbientPropertyMemberDeclaration IndexSignature
AmbientConstructorDeclaration: constructor
(
ParameterListopt )
;
12.1.4 Ambient Enum Declarations
An ambient enum is grammatically equivalent to a non-ambient enum declaration.
AmbientEnumDeclaration: EnumDeclaration
Ambient enum declarations differ from non-ambient enum declarations in two ways:
- In ambient enum declarations that specify no modifier, enum member declarations that omit a value are considered computed members (as opposed to having auto-incremented values assigned).
Ambient enum declarations are otherwise processed in the same manner as non-ambient enum declarations.
12.1.5 Ambient Namespace Declarations
An ambient namespace declaration declares a namespace.
AmbientNamespaceDeclaration: namespace
IdentifierPath {
AmbientNamespaceBody }
AmbientNamespaceBody: AmbientNamespaceElementsopt
AmbientNamespaceElements: AmbientNamespaceElement AmbientNamespaceElements AmbientNamespaceElement
Except for ImportAliasDeclarations, AmbientNamespaceElements always declare exported entities regardless of whether they include the optional export
modifier.