TypeScript Language Specification
TypeScript Language Specification
TypeScript Language Specification
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
2 Basic Concepts<br />
The remainder of this document is the formal specification of the <strong>TypeScript</strong> programming language and<br />
is intended to be read as an adjunct to the ECMAScript <strong>Language</strong> <strong>Specification</strong> (specifically, the ECMA-<br />
262 Standard, 5 th Edition). This document describes the syntactic grammar added by <strong>TypeScript</strong> along<br />
with the compile-time processing and type checking performed by the <strong>TypeScript</strong> compiler, but it only<br />
minimally discusses the run-time behavior of programs since that is covered by the ECMAScript<br />
specification.<br />
2.1 Grammar Conventions<br />
The syntactic grammar added by <strong>TypeScript</strong> language is specified throughout this document using the<br />
existing conventions and production names of the ECMAScript grammar. In places where <strong>TypeScript</strong><br />
augments an existing grammar production it is so noted. For example:<br />
CallExpression: ( Modified )<br />
…<br />
super Arguments<br />
super . Identifier<br />
The ‘( Modified )’ annotation indicates that an existing grammar production is being replaced, and the ‘…’<br />
references the contents of the original grammar production.<br />
2.2 Declarations<br />
Declarations introduce names in the declaration spaces to which they belong. It is an error to have two<br />
names with same spelling in the same declaration space. Declaration spaces exist as follows:<br />
� The global module has a declaration space for global members (variables, functions, modules, and<br />
constructor functions), and a declaration space for global types (modules, classes, and interfaces).<br />
� Each module body has a declaration space for local members (variables, functions, modules, and<br />
constructor functions), and a declaration space for local types (modules, classes, and interfaces).<br />
Every declaration (whether local or exported) in a module contributes to one or both of these<br />
declaration spaces.<br />
� Each internal or external module has a declaration space for exported members and a declaration<br />
space for exported types. All export declarations in the module contribute to these declaration<br />
spaces. Each internal module’s export declaration spaces are shared with other internal modules<br />
that have the same root module and the same qualified name starting from that root module.<br />
� Each interface type has a declaration space for its members. An interface’s declaration space is<br />
shared with other interfaces that have the same root module and the same qualified name<br />
starting from that root module.<br />
� Each object type literal has a declaration space for its members.<br />
13