Typescript Language Specification

Typescript Language Specification

TypeScript Language Specification Version 1.8 January, 2016 Microsoft is making this Specification available under the Open Web Foundation Final Specification Agreement Version 1.0 ("OWF 1.0") as of October 1, 2012. The OWF 1.0 is available at http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0. TypeScript is a trademark of Microsoft Corporation. Table of Contents 1 Introduction ................................................................................................................................................................................... 1 1.1 Ambient Declarations ..................................................................................................................................................... 3 1.2 Function Types .................................................................................................................................................................. 3 1.3 Object Types ...................................................................................................................................................................... 4 1.4 Structural Subtyping ....................................................................................................................................................... 6 1.5 Contextual Typing ............................................................................................................................................................ 7 1.6 Classes .................................................................................................................................................................................. 8 1.7 Enum Types ..................................................................................................................................................................... 10 1.8 Overloading on String Parameters......................................................................................................................... 12 1.9 Generic Types and Functions ................................................................................................................................... 12 1.10 Namespaces .................................................................................................................................................................... 14 1.11 Modules ............................................................................................................................................................................ 16 2 Basic Concepts .......................................................................................................................................................................... 17 2.1 Grammar Conventions ................................................................................................................................................ 17 2.2 Names ................................................................................................................................................................................ 17 2.2.1 Reserved Words ........................................................................................................................................................ 18 2.2.2 Property Names ........................................................................................................................................................ 18 2.2.3 Computed Property Names ................................................................................................................................. 19 2.3 Declarations ..................................................................................................................................................................... 19 2.4 Scopes ............................................................................................................................................................................... 22 3 Types ............................................................................................................................................................................................. 25 3.1 The Any Type .................................................................................................................................................................. 26 3.2 Primitive Types ............................................................................................................................................................... 26 3.2.1 The Number Type .................................................................................................................................................... 26 3.2.2 The Boolean Type .................................................................................................................................................... 27 3.2.3 The String Type ......................................................................................................................................................... 27 3.2.4 The Symbol Type ...................................................................................................................................................... 27 3.2.5 The Void Type............................................................................................................................................................ 28 3.2.6 The Null Type ............................................................................................................................................................. 28 3.2.7 The Undefined Type ................................................................................................................................................ 29 3.2.8 Enum Types ................................................................................................................................................................ 29 3.2.9 String Literal Types .................................................................................................................................................. 29 3.3 Object Types ................................................................................................................................................................... 29 3.3.1 Named Type References ....................................................................................................................................... 30 3.3.2 Array Types ................................................................................................................................................................. 30 3.3.3 Tuple Types ................................................................................................................................................................ 30 3.3.4 Function Types .......................................................................................................................................................... 31 3.3.5 Constructor Types .................................................................................................................................................... 31 i 3.3.6 Members ..................................................................................................................................................................... 31 3.4 Union Types..................................................................................................................................................................... 32 3.5 Intersection Types ......................................................................................................................................................... 34 3.6 Type Parameters ............................................................................................................................................................ 35 3.6.1 Type Parameter Lists ............................................................................................................................................... 35 3.6.2 Type Argument Lists ............................................................................................................................................... 36 3.6.3 This-types .................................................................................................................................................................... 37 3.7 Named Types .................................................................................................................................................................. 38 3.8 Specifying Types ............................................................................................................................................................ 39 3.8.1 Predefined Types ...................................................................................................................................................... 39 3.8.2 Type References ....................................................................................................................................................... 40 3.8.3 Object Type Literals ................................................................................................................................................. 41 3.8.4 Array Type Literals ................................................................................................................................................... 42 3.8.5 Tuple Type Literals

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    192 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us