没有合适的资源?快使用搜索试试~ 我知道了~
首页TypeScript语言规范1.8
TypeScript语言规范1.8
需积分: 13 30 下载量 66 浏览量
更新于2023-05-31
评论 1
收藏 1.62MB PDF 举报
TypeScript Language Specification。Version 1.8。January, 2016。
资源详情
资源评论
资源推荐
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.
i
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
ii
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 ................................................................................................................................................... 42
3.8.6 Union Type Literals .................................................................................................................................................. 43
3.8.7 Intersection Type Literals ...................................................................................................................................... 43
3.8.8 Function Type Literals ............................................................................................................................................ 43
3.8.9 Constructor Type Literals ...................................................................................................................................... 44
3.8.10 Type Queries .............................................................................................................................................................. 44
3.8.11 This-Type References ............................................................................................................................................. 45
3.9 Specifying Members .................................................................................................................................................... 46
3.9.1 Property Signatures................................................................................................................................................. 46
3.9.2 Call Signatures........................................................................................................................................................... 46
3.9.3 Construct Signatures .............................................................................................................................................. 50
3.9.4 Index Signatures ....................................................................................................................................................... 50
3.9.5 Method Signatures .................................................................................................................................................. 51
3.10 Type Aliases ..................................................................................................................................................................... 52
3.11 Type Relationships ........................................................................................................................................................ 54
3.11.1 Apparent Members ................................................................................................................................................. 54
3.11.2 Type and Member Identity ................................................................................................................................... 56
3.11.3 Subtypes and Supertypes ..................................................................................................................................... 57
3.11.4 Assignment Compatibility .................................................................................................................................... 58
3.11.5 Excess Properties ...................................................................................................................................................... 59
3.11.6 Contextual Signature Instantiation ................................................................................................................... 61
3.11.7 Type Inference ........................................................................................................................................................... 61
3.11.8 Recursive Types ........................................................................................................................................................ 62
3.12 Widened Types .............................................................................................................................................................. 63
4 Expressions ................................................................................................................................................................................. 65
4.1 Values and References ................................................................................................................................................ 65
4.2 The this Keyword ........................................................................................................................................................... 65
4.3 Identifiers.......................................................................................................................................................................... 66
iii
4.4 Literals ............................................................................................................................................................................... 66
4.5 Object Literals ................................................................................................................................................................. 66
4.6 Array Literals ................................................................................................................................................................... 68
4.7 Template Literals ........................................................................................................................................................... 69
4.8 Parentheses ..................................................................................................................................................................... 69
4.9 The super Keyword ....................................................................................................................................................... 70
4.9.1 Super Calls .................................................................................................................................................................. 70
4.9.2 Super Property Access ........................................................................................................................................... 70
4.10 Function Expressions ................................................................................................................................................... 71
4.11 Arrow Functions ............................................................................................................................................................. 72
4.12 Class Expressions ........................................................................................................................................................... 74
4.13 Property Access ............................................................................................................................................................. 74
4.14 The new Operator ......................................................................................................................................................... 75
4.15 Function Calls ................................................................................................................................................................. 76
4.15.1 Overload Resolution ............................................................................................................................................... 76
4.15.2 Type Argument Inference ..................................................................................................................................... 77
4.15.3 Grammar Ambiguities ............................................................................................................................................ 80
4.16 Type Assertions .............................................................................................................................................................. 80
4.17 JSX Expressions .............................................................................................................................................................. 81
4.18 Unary Operators ............................................................................................................................................................ 81
4.18.1 The ++ and -- operators ....................................................................................................................................... 82
4.18.2 The +, –, and ~ operators ..................................................................................................................................... 82
4.18.3 The ! operator ............................................................................................................................................................ 82
4.18.4 The delete Operator ................................................................................................................................................ 82
4.18.5 The void Operator ................................................................................................................................................... 82
4.18.6 The typeof Operator ............................................................................................................................................... 83
4.19 Binary Operators ........................................................................................................................................................... 83
4.19.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators ...................................................................................... 83
4.19.2 The + operator .......................................................................................................................................................... 83
4.19.3 The <, >, <=, >=, ==, !=, ===, and !== operators ................................................................................... 84
4.19.4 The instanceof operator ........................................................................................................................................ 84
4.19.5 The in operator ......................................................................................................................................................... 85
4.19.6 The && operator ...................................................................................................................................................... 85
4.19.7 The || operator ........................................................................................................................................................... 85
4.20 The Conditional Operator .......................................................................................................................................... 86
4.21 Assignment Operators ................................................................................................................................................ 86
4.21.1 Destructuring Assignment .................................................................................................................................... 86
4.22 The Comma Operator ................................................................................................................................................. 87
4.23 Contextually Typed Expressions .............................................................................................................................. 88
4.24 Type Guards .................................................................................................................................................................... 89
5 Statements .................................................................................................................................................................................. 95
剩余191页未读,继续阅读
qq_29893569
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0