语法
本附录包含了主文档中出现的所有语法的汇总。
1.1 类型
TypeParameters:
< TypeParameterList >
类型参数集:
<类型参数列表>
TypeParameterList:
TypeParameter
TypeParameterList , TypeParameter
类型参数列表:
类型参数
类型参数列表,类型参数
TypeParameter:
Identifier Constraintopt
类型参数:
标识符约束(可选)
Constraint:
extends Type
约束:
extends类型
Type:
PredefinedType
TypeReference
TypeQuery
TypeLiteral
类型:
预定义类型
类型引用
类型查询
类型描述
PredefinedType:
any
number
boolean
string
void
预定义类型:
any
number
boolean
string
void
TypeReference:
TypeName [no LineTerminator here] TypeArgumentsopt
类型引用:
类型名[这里没有换行符] 类型参数集(可选)
TypeName:
Identifier
ModuleName . Identifier
类型名:
标识符
模块名称.标识符
ModuleName:
Identifier
ModuleName . Identifier
模块名称:
标识符
模块名称.标识符
TypeArguments:
< TypeArgumentList >
类型参数集:
<类型参数列表>
TypeArgumentList:
TypeArgument
TypeArgumentList , TypeArgument
类型参数列表:
类型参数
类型参数列表,类型参数
TypeArgument:
Type
类型参数:
类型
TypeQuery:
typeof TypeQueryExpression
类型查询:
typeof 类型查询表达式
TypeQueryExpression:
Identifier
TypeQueryExpression . IdentifierName
类型查询表达式:
标识符
类型查询表达式. 标识符名称
TypeLiteral:
ObjectType
ArrayType
FunctionType
ConstructorType
类型描述:
对象类型
数组类型
函数类型
构造函数类型
ArrayType:
ElementType [no LineTerminator here][]
数组类型:
元素类型[这里没有换行符] []
ElementType:
PredefinedType
TypeReference
TypeQuery
ObjectType
ArrayType
元素类型:
预定义类型
类型引用
类型查询
对象类型
数组类型
FunctionType:
TypeParametersopt( ParameterListopt)=> Type
函数类型:
类型参数(可选)(参数列表(可选))=>类型
ConstructorType:
newTypeParametersopt( ParameterListopt)=> Type
构造函数类型:
new 类型参数(可选)(参数列表(可选))=>类型
ObjectType:
{ TypeBodyopt}
对象类型:
{ 类型体(可选)}
TypeBody:
TypeMemberList ;opt
类型体:
类型成员列表 ;(可选)
TypeMemberList:
TypeMember
TypeMemberList ; TypeMember
类型成员列表:
类型成员
类型成员列表; 类型成员
TypeMember:
PropertySignature
CallSignature
ConstructSignature
IndexSignature
MethodSignature
类型成员:
属性标记
调用标记
构造函数标记
索引标记
方法标记
PropertySignature:
PropertyName ?opt TypeAnnotationopt
属性标记:
属性名称 ?(可选)类型说明(可选)
PropertyName:
IdentifierName
StringLiteral
NumericLiteral
属性名称:
标识符名称
字符串值
数字文本
CallSignature:
TypeParametersopt( ParameterListopt) TypeAnnotationopt
调用标记:
类型参数(可选)( 参数列表(可选)) 类型说明(可选)
ParameterList:
RequiredParameterList
OptionalParameterList
RestParameter
RequiredParameterList , OptionalParameterList
RequiredParameterList , RestParameter
OptionalParameterList , RestParameter
RequiredParameterList , OptionalParameterList , RestParameter
参数列表:
必要参数列表
可选参数列表
其余参数
必要参数列表, 可选参数列表
必要参数列表, 其余参数
可选参数列表, 其余参数
必要参数列表, 可选参数列表, 其余参数
RequiredParameterList:
RequiredParameter
RequiredParameterList , RequiredParameter
必要参数列表:
必要参数
必要参数列表, 必要参数
RequiredParameter:
PublicOrPrivateopt Identifier TypeAnnotationopt
Identifier : StringLiteral
必要参数:
访问控制符(可选)标识符类型说明(可选)
标识符: 字符串值
PublicOrPrivate:
public
private
访问控制符:
public
private
OptionalParameterList:
OptionalParameter
OptionalParameterList , OptionalParameter
可选参数列表:
可选参数
可选参数列表, 可选参数
OptionalParameter:
PublicOrPrivateopt Identifier ? TypeAnnotationopt
PublicOrPrivateopt Identifier TypeAnnotationopt Initialiser
Identifier ?: StringLiteral
可选参数:
访问控制符(可选)标识符?类型说明(可选)
访问控制符(可选)标识符类型说明(可选)初始化
标识符?:字符串值
RestParameter:
... Identifier TypeAnnotationopt
其余参数:
...标识符类型说明(可选)
ConstructSignature:
new TypeParametersopt( ParameterListopt) TypeAnnotationopt
构造函数标记:
new 类型参数集(可选)( 参数列表(可选)) 类型说明(可选)
IndexSignature:
[ Identifier :string] TypeAnnotation
[ Identifier :number] TypeAnnotation
索引标记:
[标识符:string ]类型说明
[标识符:number]类型说明
MethodSignature:
PropertyName ?opt CallSignature
方法标记:
属性名称?(可选)调用标记
1.2 Expressions表达式
PropertyAssignment: ( Modified )
PropertyName : AssignmentExpression
PropertyName CallSignature { FunctionBody }
GetAccessor
SetAccessor
属性赋值:(改动)
属性名:赋值表达式
属性名调用标记{函数体}
Getter
Setter
GetAccessor:
get PropertyName () TypeAnnotationopt{ FunctionBody }
Getter:
get 属性名() 类型说明(可选) { 函数体 }
SetAccessor:
set PropertyName ( Identifier TypeAnnotationopt){ FunctionBody }
Setter:
set属性名 ( 标识符类型说明(可选) ) { 函数体 }
CallExpression: ( Modified )
…
super( ArgumentListopt)
super. IdentifierName
调用表达式:(改动)
…
super( 参数列表(可选))
super. 标识符名称
FunctionExpression: ( Modified )
function Identifieropt CallSignature { FunctionBody }
函数表达式:(改动)
function 标识符(可选)
AssignmentExpression: ( Modified )
…
ArrowFunctionExpression
赋值表达式:(改动)
…
箭头函数表达式
ArrowFunctionExpression:
ArrowFormalParameters => Block
ArrowFormalParameters => AssignmentExpression
箭头函数表达式:
箭头形参集 =>块
箭头形参集 =>赋值表达式
ArrowFormalParameters:
CallSignature
Identifier
箭头形参集:
调用标记
标识符
Arguments: ( Modified )
TypeArgumentsopt( ArgumentListopt)
参数:(改动)
类型参数集(可选) ( 参数列表(可选) )
UnaryExpression: ( Modified )
…
< Type > UnaryExpression
一元表达式:(改动)
…
<类型>一元表达式
1.3 状态说明
VariableDeclaration: ( Modified )
Identifier TypeAnnotationopt Initialiseropt
变量声明:(改动)
标识符类型说明(可选)初始化(可选)
VariableDeclarationNoIn: ( Modified )
Identifier TypeAnnotationopt InitialiserNoInopt
变量声明NoIn(什么No In毛东西特么实在看不懂了我去!):(改动)
标识符类型说明(可选)初始化No In(可选,而且看不懂)
TypeAnnotation:
: Type
类型说明:
: 类型
1.4 函数
FunctionDeclaration: ( Modified )
FunctionOverloadsopt FunctionImplementation
函数声明:(改动)
多个函数重载(可选)函数实现
FunctionOverloads:
FunctionOverload
FunctionOverloads FunctionOverload
多个函数重载:
函数重载
多个函数重载函数重载
FunctionOverload:
function Identifier CallSignature ;
函数重载:
function 标识符调用标记 ;
FunctionImplementation:
function Identifier CallSignature { FunctionBody }
函数实现:
function 标识符调用标记 {函数体}
1.5 接口
InterfaceDeclaration:
interface Identifier TypeParametersopt InterfaceExtendsClauseopt ObjectType
接口声明:
interface 标识符类型说明(可选)接口扩展条款(可选)对象类型
InterfaceExtendsClause:
extends ClassOrInterfaceTypeList
接口扩展条款:
extends 类或接口类型列表
ClassOrInterfaceTypeList:
ClassOrInterfaceType
ClassOrInterfaceTypeList , ClassOrInterfaceType
类或接口类型列表:
类或接口类型
类或接口类型列表 , 类或接口类型
ClassOrInterfaceType:
TypeReference
类或接口类型:
类型引用
1.6 类
ClassDeclaration:
class Identifier TypeParametersopt ClassHeritage { ClassBody }
类声明:
class 标识符类型参数(可选)类继承 {类体}
ClassHeritage:
ClassExtendsClauseopt ImplementsClauseopt
类继承:
类扩展条款(可选)实现条款(可选)
ClassExtendsClause:
extends ClassType
类扩展条款:
extends 类类型
ClassType:
TypeReference
类类型:
类型引用
ImplementsClause:
implements ClassOrInterfaceTypeList
实现条款:
implements 类或接口类型列表
ClassBody:
ClassElementsopt
类体:
类元素集(可选)
ClassElements:
ClassElement
ClassElements ClassElement
类元素集:
类元素
类元素集类元素
ClassElement:
ConstructorDeclaration
PropertyMemberDeclaration
IndexMemberDeclaration
类元素:
构造函数声明
属性成员声明
索引成员声明
ConstructorDeclaration:
ConstructorOverloadsopt ConstructorImplementation
构造函数声明:
多个构造函数重载(可选)构造函数实现
ConstructorOverloads:
ConstructorOverload
ConstructorOverloads ConstructorOverload
多个构造函数重载:
构造函数重载
多个构造函数重载构造函数重载
ConstructorOverload:
PublicOrPrivateoptconstructor( ParameterListopt);
构造函数重载:
访问控制符(可选) constructor( 参数列表(可选) )
ConstructorImplementation:
PublicOrPrivateoptconstructor( ParameterListopt){ FunctionBody }
构造函数实现:
访问控制符(可选) constructor( 参数列表(可选) ) { 函数体 }
PropertyMemberDeclaration:
MemberVariableDeclaration
MemberFunctionDeclaration
MemberAccessorDeclaration
属性成员声明:
成员变量声明
成员函数声明
成员访问声明
MemberVariableDeclaration:
PublicOrPrivateoptstaticopt PropertyName TypeAnnotationopt Initialiseropt;
成员变量声明:
访问控制符(可选) static(可选)属性名类型说明(可选)初始化(可选)
MemberFunctionDeclaration:
MemberFunctionOverloadsopt MemberFunctionImplementation
成员函数声明:
多个成员函数重载(可选)成员函数实现
MemberFunctionOverloads:
MemberFunctionOverload
MemberFunctionOverloads MemberFunctionOverload
多个成员函数重载:
成员函数重载
多个成员函数重载成员函数重载
MemberFunctionOverload:
PublicOrPrivateoptstaticopt PropertyName CallSignature ;
成员函数重载:
访问控制符(可选) static(可选)属性名调用标记 ;
MemberFunctionImplementation:
PublicOrPrivateoptstaticopt PropertyName CallSignature { FunctionBody }
成员函数实现:
访问控制符(可选) static(可选)属性名调用标记 {函数体 }
MemberAccessorDeclaration:
PublicOrPrivateoptstaticoptGetAccessor
PublicOrPrivateoptstaticoptSetAccessor
成员访问声明:
访问控制符(可选) static(可选)Getter
访问控制符(可选) static(可选)Setter
IndexMemberDeclaration:
IndexSignature ;
索引成员声明:
索引标记
1.7 枚举
EnumDeclaration:
enum Identifier { EnumBodyopt}
枚举声明:
enum标识符 {枚举体(可选) }
EnumBody:
ConstantEnumMembers ,opt
ConstantEnumMembers , EnumMemberSections ,opt
EnumMemberSections ,opt
枚举体:
多个常量枚举成员 ,(可选)
多个常量枚举成员 , 多个枚举成员项 ,(可选)
多个枚举成员项 ,(可选)
ConstantEnumMembers:
PropertyName
ConstantEnumMembers , PropertyName
多个常量枚举成员:
属性名
多个常量枚举成员 , 属性名
EnumMemberSections:
EnumMemberSection
EnumMemberSections , EnumMemberSection
多个枚举成员项:
枚举成员项
多个枚举成员项 , 枚举成员项
EnumMemberSection:
ConstantEnumMemberSection
ComputedEnumMember
枚举成员项:
常量枚举成员项
计算量枚举成员
ConstantEnumMemberSection:
PropertyName = ConstantEnumValue
PropertyName = ConstantEnumValue , ConstantEnumMembers
常量枚举成员项:
属性名= 常量枚举值
属性名= 常量枚举值 , 多个常量枚举成员
ConstantEnumValue:
SignedInteger
HexIntegerLiteral
常量枚举值:
带符号的整数
十六进制整数的字母描述
ComputedEnumMember:
PropertyName = AssignmentExpression
计算量枚举成员:
属性名= 赋值表达式
1.8 内部模块
ModuleDeclaration:
module IdentifierPath { ModuleBody }
模块声明:
module标识符路径{模块体}
IdentifierPath:
Identifier
IdentifierPath . Identifier
标识符路径:
标识符
标识符路径.标识符
ModuleBody:
ModuleElementsopt
模块体:
模块元素集(可选)
ModuleElements:
ModuleElement
ModuleElements ModuleElement
模块元素集:
模块元素
模块元素集模块元素
ModuleElement:
Statement
exportopt VariableDeclaration
exportopt FunctionDeclaration
exportopt ClassDeclaration
exportopt InterfaceDeclaration
exportopt EnumDeclaration
exportopt ModuleDeclaration
exportopt ImportDeclaration
模块元素:
状态
export(可选)变量声明
export(可选)函数声明
export(可选)类声明
export(可选)接口声明
export(可选)枚举声明
export(可选)模块声明
export(可选)导入声明
ImportDeclaration:
import Identifier =EntityName ;
导入声明:
import标识符=实体名 ;
EntityName:
Identifier
ModuleName . Identifier
实体名:
标识符
模块名.标识符
1.9 程序与外部模块
SourceFile:
ImplementationSourceFile
DeclarationSourceFile
源文件:
实现源文件
声明源文件
ImplementationSourceFile:
ImplementationElementsopt
实现源文件:
实现元素集(可选)
ImplementationElements:
ImplementationElement
ImplementationElements ImplementationElement
实现元素集:
实现元素
实现元素集实现元素
ImplementationElement:
ModuleElement
ExportAssignment
AmbientExternalModuleDeclaration
exportopt ExternalImportDeclaration
实现元素:
模块元素
导出赋值
环境外部模块声明
export(可选)外部导入声明
DeclarationSourceFile:
DeclarationElementsopt
声明源文件:
声明元素集
DeclarationElements:
DeclarationElement
DeclarationElements DeclarationElement
声明元素集:
声明元素
声明元素集声明元素
DeclarationElement:
ExportAssignment
AmbientExternalModuleDeclaration
exportopt InterfaceDeclaration
exportopt ImportDeclaration
exportopt AmbientDeclaration
exportopt ExternalImportDeclaration
声明元素:
导出赋值
环境外部模块声明
export(可选)接口声明
export(可选)导入声明
export(可选)环境声明
export(可选)外部导入声明
ExternalImportDeclaration:
import Identifier =ExternalModuleReference ;
外部导入声明:
import标识符=外部模块引用 ;
ExternalModuleReference:
require( StringLiteral )
外部模块引用:
require( 字符串值 )
ExportAssignment:
export= Identifier ;
导出赋值:
export= 标识符 ;
1.10 Ambients
AmbientDeclaration:
declare AmbientVariableDeclaration
declare AmbientFunctionDeclaration
declare AmbientClassDeclaration
declare AmbientEnumDeclaration
declare AmbientModuleDeclaration
环境声明:
declare环境变量声明
declare环境函数声明
declare环境类声明
declare环境枚举声明
declare环境模块声明
AmbientVariableDeclaration:
var Identifier TypeAnnotationopt;
环境变量声明:
var标识符类型说明(可选);
AmbientFunctionDeclaration:
function Identifier CallSignature ;
环境函数声明:
function标识符调用标记;
AmbientClassDeclaration:
class Identifier TypeParametersopt ClassHeritage { AmbientClassBody }
环境类声明:
class标识符类型参数(可选)类继承{环境类体}
AmbientClassBody:
AmbientClassBodyElementsopt
环境类体:
多个环境类体元素(可选)
AmbientClassBodyElements:
AmbientClassBodyElement
AmbientClassBodyElements AmbientClassBodyElement
多个环境类体元素:
环境类体元素
多个环境类体元素环境类体元素
AmbientClassBodyElement:
AmbientConstructorDeclaration
AmbientPropertyMemberDeclaration
IndexSignature
环境类体元素:
环境构造函数声明
环境属性成员声明
索引标记
AmbientConstructorDeclaration:
constructor( ParameterListopt);
环境构造函数声明:
constructor(参数列表 );
AmbientPropertyMemberDeclaration:
PublicOrPrivateoptstaticopt PropertyName TypeAnnotationopt;
PublicOrPrivateoptstaticopt PropertyName CallSignature ;
环境属性成员声明:
访问控制符(可选)static(可选)属性名类型说明(可选);
访问控制符(可选) static(可选)属性名调用标记;
AmbientEnumDeclaration:
enum Identifier { AmbientEnumBodyopt}
环境枚举声明:
enum标识符{环境枚举体(可选)}
AmbientEnumBody:
AmbientEnumMemberList ,opt
环境枚举体:
环境枚举成员列表,(可选)
AmbientEnumMemberList:
AmbientEnumMember
AmbientEnumMemberList , AmbientEnumMember
环境枚举成员列表:
环境枚举成员
环境枚举成员列表,环境枚举成员
AmbientEnumMember:
PropertyName
PropertyName = ConstantEnumValue
环境枚举成员:
属性名
属性名= 常量枚举值
AmbientModuleDeclaration:
moduleIdentifierPath{ AmbientModuleBody}
环境模块声明:
module标识符路径{环境模块体}
AmbientModuleBody:
AmbientModuleElementsopt
环境模块体:
多个环境模块元素(可选)
AmbientModuleElements:
AmbientModuleElement
AmbientModuleElements AmbientModuleElement
多个环境模块元素:
环境模块元素
多个环境模块元素环境模块元素
AmbientModuleElement:
exportopt AmbientVariableDeclaration
exportopt AmbientFunctionDeclaration
exportopt AmbientClassDeclaration
exportopt InterfaceDeclaration
exportopt AmbientEnumDeclaration
exportoptAmbientModuleDeclaration
exportopt ImportDeclaration
环境模块元素:
export(可选)环境变量声明
export(可选)环境函数声明
export(可选)环境类声明
export(可选)接口声明
export(可选)环境枚举声明
export(可选)环境模块声明
export(可选)导入声明
AmbientExternalModuleDeclaration:
module StringLiteral { AmbientExternalModuleBody }
环境外部模块声明:
module字符串值{环境外部模块体}
AmbientExternalModuleBody:
AmbientExternalModuleElementsopt
环境外部模块体:
多个环境外部模块元素(可选)
AmbientExternalModuleElements:
AmbientExternalModuleElement
AmbientExternalModuleElements AmbientExternalModuleElement
多个环境外部模块元素:
环境外部模块元素
多个环境外部模块元素环境外部模块元素
AmbientExternalModuleElement:
AmbientModuleElement
ExportAssignment
exportopt ExternalImportDeclaration
环境外部模块元素:
环境模块元素
导出赋值
export(可选)外部导入声明
|