没有合适的资源?快使用搜索试试~ 我知道了~
首页TypeScript 语言规范 (英文PDF)
TypeScript 语言规范 (英文PDF)
需积分: 35 44 下载量 139 浏览量
更新于2023-03-16
评论 3
收藏 887KB PDF 举报
TypeScript 语言规范 (英文PDF) TypeScript是微软新开发的一套构建于JavaScript之上的开发语言,其弥补了JavaScript不易于开发、调试的缺点,并且语法完全兼容ECMAScript 5, 同时包含了部分ECMAScript 6的内容。 TypeScript自身无法执行,TypeScript的编译器将TS代码转换成标准的JS代码,因此可以在任何现代浏览器上执行。和Dart及GWT等类似工具不同的是,TypeScript生成的JS非常短小高效,并且由于完全兼容JavaScript,使用第三方JS库的时候(例如PhoneGap或jQuery)是不需要写任何导入库的。尽管如此,网络上还是有许多现成的TypeScript“界面定义”以方便开发员用面向对象的方式访问这些第三方JS库。 微软的TypeScript演示页面:www.typescriptlang.org TypeScript界面定义:https://github.com/borisyankov/DefinitelyTyped
资源详情
资源评论
资源推荐
TypeScript
Language Specification
Version 0.8
October 2012
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 .................................................................................................................................................................................. 7
1.7 Modules ............................................................................................................................................................................ 10
2 Basic Concepts .......................................................................................................................................................................... 13
2.1 Grammar Conventions ................................................................................................................................................ 13
2.2 Declarations ..................................................................................................................................................................... 13
2.3 Scopes ............................................................................................................................................................................... 15
3 Types ............................................................................................................................................................................................. 17
3.1 The Any Type .................................................................................................................................................................. 18
3.2 Primitive Types ............................................................................................................................................................... 18
3.2.1 The Number Type .................................................................................................................................................... 18
3.2.2 The Boolean Type .................................................................................................................................................... 19
3.2.3 The String Type ......................................................................................................................................................... 19
3.2.4 The Null Type ............................................................................................................................................................. 19
3.2.5 The Undefined Type ................................................................................................................................................ 20
3.3 Object Types ................................................................................................................................................................... 20
3.4 The Void Type ................................................................................................................................................................. 21
3.5 Specifying Types ............................................................................................................................................................ 22
3.5.1 Predefined Types ...................................................................................................................................................... 22
3.5.2 Type Names ............................................................................................................................................................... 23
3.5.3 Object Type Literals ................................................................................................................................................. 23
3.5.4 Array Type Literals ................................................................................................................................................... 26
3.5.5 Function Type Literals ............................................................................................................................................ 26
3.5.6 Constructor Type Literals ...................................................................................................................................... 27
3.6 Type Relationships ........................................................................................................................................................ 27
3.6.1 Type identity .............................................................................................................................................................. 28
3.6.2 Subtypes and Supertypes ..................................................................................................................................... 28
3.6.3 Assignment Compatibility .................................................................................................................................... 28
3.7 Widened Types .............................................................................................................................................................. 29
3.8 The Best Common Type ............................................................................................................................................. 30
4 Expressions ................................................................................................................................................................................. 31
4.1 Values and References ................................................................................................................................................ 31
4.2 The this Keyword ........................................................................................................................................................... 31
ii
4.3 Identifiers.......................................................................................................................................................................... 32
4.4 Literals ............................................................................................................................................................................... 32
4.5 Object Literals ................................................................................................................................................................. 32
4.6 Array Literals ................................................................................................................................................................... 32
4.7 Parentheses ..................................................................................................................................................................... 33
4.8 The super Keyword ....................................................................................................................................................... 33
4.8.1 Super Calls .................................................................................................................................................................. 33
4.8.2 Super Property Access ........................................................................................................................................... 33
4.9 Function Expressions ................................................................................................................................................... 34
4.9.1 Standard Function Expressions ........................................................................................................................... 34
4.9.2 Arrow Function Expressions ................................................................................................................................. 35
4.10 Property Access ............................................................................................................................................................. 36
4.11 The new Operator ......................................................................................................................................................... 37
4.12 Function Calls ................................................................................................................................................................. 37
4.13 Type Assertions .............................................................................................................................................................. 38
4.14 Unary Operators ............................................................................................................................................................ 39
4.14.1 The ++ and -- operators ....................................................................................................................................... 40
4.14.2 The +, –, and ~ operators ..................................................................................................................................... 40
4.14.3 The ! operator ............................................................................................................................................................ 40
4.14.4 The delete Operator ................................................................................................................................................ 40
4.14.5 The void Operator ................................................................................................................................................... 40
4.14.6 The typeof Operator ............................................................................................................................................... 40
4.15 Binary Operators ........................................................................................................................................................... 40
4.15.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators ...................................................................................... 41
4.15.2 The + operator .......................................................................................................................................................... 41
4.15.3 The <, >, <=, >=, ==, !=, ===, and !== operators ................................................................................... 42
4.15.4 The instanceof operator ........................................................................................................................................ 42
4.15.5 The in operator ......................................................................................................................................................... 42
4.15.6 The && operator ...................................................................................................................................................... 42
4.15.7 The || operator ........................................................................................................................................................... 43
4.16 The Conditional Operator .......................................................................................................................................... 43
4.17 Assignment Operators ................................................................................................................................................ 43
4.18 Contextually Typed Expressions .............................................................................................................................. 44
5 Statements .................................................................................................................................................................................. 47
5.1 Variable Statements ..................................................................................................................................................... 47
6 Functions ..................................................................................................................................................................................... 49
6.1 Function Declarations .................................................................................................................................................. 49
6.2 Function Signatures ..................................................................................................................................................... 49
6.3 Function Overloads ...................................................................................................................................................... 51
6.4 Function Implementations ........................................................................................................................................ 52
6.5 Code Generation ........................................................................................................................................................... 53
iii
7 Interfaces ..................................................................................................................................................................................... 55
7.1 Interface Declarations ................................................................................................................................................. 55
7.2 Dynamic Type Checks ................................................................................................................................................. 56
8 Classes .......................................................................................................................................................................................... 59
8.1 Class Declarations ......................................................................................................................................................... 59
8.1.1 Class Heritage Specification ................................................................................................................................ 60
8.1.2 Class Body ................................................................................................................................................................... 61
8.2 Members........................................................................................................................................................................... 61
8.2.1 Accessibility ................................................................................................................................................................ 62
8.2.2 Inheritance and Overriding .................................................................................................................................. 62
8.2.3 Class Instance Types ............................................................................................................................................... 62
8.2.4 Constructor Function Types ................................................................................................................................. 63
8.3 Constructor Declarations ........................................................................................................................................... 64
8.3.1 Constructor Parameters ......................................................................................................................................... 64
8.3.2 Super Calls .................................................................................................................................................................. 65
8.3.3 Automatic Constructors ........................................................................................................................................ 66
8.4 Member Declarations .................................................................................................................................................. 66
8.4.1 Member Variable Declarations ........................................................................................................................... 67
8.4.2 Member Function Declarations .......................................................................................................................... 68
8.4.3 Member Accessor Declarations .......................................................................................................................... 69
8.5 Code Generation ........................................................................................................................................................... 70
8.5.1 Classes Without Extends Clauses ....................................................................................................................... 70
8.5.2 Classes With Extends Clauses .............................................................................................................................. 72
9 Programs and Modules ......................................................................................................................................................... 75
9.1 Programs .......................................................................................................................................................................... 75
9.1.1 Source Files Dependencies................................................................................................................................... 76
9.2 Module Declarations.................................................................................................................................................... 77
9.2.1 Export Declarations ................................................................................................................................................. 77
9.2.2 Import Declarations ................................................................................................................................................ 78
9.2.3 Module Identifiers ................................................................................................................................................... 79
9.3 Internal Modules ........................................................................................................................................................... 80
9.4 External Modules ........................................................................................................................................................... 83
9.4.1 External Module Names ........................................................................................................................................ 83
9.4.2 CommonJS Modules ............................................................................................................................................... 84
9.4.3 AMD Modules ........................................................................................................................................................... 86
9.5 Code Generation ........................................................................................................................................................... 86
9.5.1 Internal Modules ...................................................................................................................................................... 86
10 Ambients...................................................................................................................................................................................... 89
10.1 Ambient Declarations .................................................................................................................................................. 89
10.1.1 Ambient Variable Declarations ........................................................................................................................... 89
10.1.2 Ambient Function Declarations .......................................................................................................................... 89
剩余96页未读,继续阅读
horeaper
- 粉丝: 0
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 数据结构1800题含完整答案详解.doc
- 医疗企业薪酬系统设计与管理方案.pptx
- 界面与表面技术界面理论与表面技术要点PPT学习教案.pptx
- Java集合排序及java集合类详解(Collection、List、Map、Set)讲解.pdf
- 网页浏览器的开发 (2).pdf
- 路由器原理与设计讲稿6-交换网络.pptx
- 火电厂锅炉过热汽温控制系统设计.doc
- 企业识别CIS系统手册[收集].pdf
- 物业管理基础知识.pptx
- 第4章财务预测.pptx
- 《集成电路工艺设计及器件特性分析》——实验教学计算机仿真系.pptx
- 局域网内共享文件提示没有访问权限的问题借鉴.pdf
- 第5章网络营销策略.pptx
- 固井质量测井原理PPT教案.pptx
- 毕业实习总结6篇.doc
- UGNX建模基础篇草图模块PPT学习教案.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0