TypeScript Language Specification v1.5
TypeScript Language Specification v1.5
TypeScript Language Specification v1.5
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Table of Contents<br />
1 Introduction ................................................................................................................................................................................... 1<br />
1.1 Ambient Declarations ..................................................................................................................................................... 3<br />
1.2 Function Types .................................................................................................................................................................. 3<br />
1.3 Object Types ...................................................................................................................................................................... 4<br />
1.4 Structural Subtyping ....................................................................................................................................................... 6<br />
1.5 Contextual Typing ............................................................................................................................................................ 7<br />
1.6 Classes .................................................................................................................................................................................. 8<br />
1.7 Enum Types ..................................................................................................................................................................... 10<br />
1.8 Overloading on String Parameters......................................................................................................................... 11<br />
1.9 Generic Types and Functions ................................................................................................................................... 12<br />
1.10 Modules ............................................................................................................................................................................ 14<br />
2 Basic Concepts .......................................................................................................................................................................... 17<br />
2.1 Grammar Conventions ................................................................................................................................................ 17<br />
2.2 Namespaces and Named Types .............................................................................................................................. 17<br />
2.3 Declarations ..................................................................................................................................................................... 18<br />
2.4 Scopes ............................................................................................................................................................................... 20<br />
3 Types ............................................................................................................................................................................................. 23<br />
3.1 The Any Type .................................................................................................................................................................. 24<br />
3.2 Primitive Types ............................................................................................................................................................... 24<br />
3.2.1 The Number Type .................................................................................................................................................... 24<br />
3.2.2 The Boolean Type .................................................................................................................................................... 25<br />
3.2.3 The String Type ......................................................................................................................................................... 25<br />
3.2.4 The Void Type............................................................................................................................................................ 25<br />
3.2.5 The Null Type ............................................................................................................................................................. 26<br />
3.2.6 The Undefined Type ................................................................................................................................................ 26<br />
3.2.7 Enum Types ................................................................................................................................................................ 26<br />
3.2.8 String Literal Types .................................................................................................................................................. 27<br />
3.3 Object Types ................................................................................................................................................................... 27<br />
3.3.1 Named Type References ....................................................................................................................................... 27<br />
3.3.2 Array Types ................................................................................................................................................................. 27<br />
3.3.3 Tuple Types ................................................................................................................................................................ 28<br />
3.3.4 Function Types .......................................................................................................................................................... 29<br />
3.3.5 Constructor Types .................................................................................................................................................... 29<br />
3.3.6 Members ..................................................................................................................................................................... 29<br />
3.4 Union Types..................................................................................................................................................................... 30<br />
3.4.1 Contextual Union Types ........................................................................................................................................ 31<br />
3.5 Type Parameters ............................................................................................................................................................ 32<br />
3.5.1 Type Parameter Lists ............................................................................................................................................... 32<br />
i