# @babel/类型
该模块包含用于手动构建 AST 和检查 AST 节点类型的方法。
# 安装
- npm
npm install --save-dev @babel/types
- yarn
yarn add --dev @babel/types
# 应用程序接口
# 节点构建器 (opens new window)
# anyTypeAnnotation
JavaScript
t.anyTypeAnnotation();
另见t.isAnyTypeAnnotation(node, opts)和t.assertAnyTypeAnnotation(node, opts)。
别名:Flow (opens new window) , FlowType ,FlowBaseAnnotation (opens new window)
# 参数占位符
JavaScript
t.argumentPlaceholder();
另见t.isArgumentPlaceholder(node, opts)和t.assertArgumentPlaceholder(node, opts)。
# 数组表达式
JavaScript
t.arrayExpression(elements);
另见t.isArrayExpression(node, opts)和t.assertArrayExpression(node, opts)。
AST节点ArrayExpression形状:
elements:Array<js | Expression | SpreadElement>(默认:[])
别名: Standardized ,Expression (opens new window)
# 数组模式
JavaScript
t.arrayPattern(elements);
另见t.isArrayPattern(node, opts)和t.assertArrayPattern(node, opts)。
AST节点ArrayPattern形状:
elements:Array<js | PatternLike | LVal>(必填)decorators:(Array<Decorator>默认值:js,从构建函数中排除)optional:(boolean默认值:js,从构建函数中排除)typeAnnotation:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Pattern , PatternLike ,LVal (opens new window)
# arrayTypeAnnotation
JavaScript
t.arrayTypeAnnotation(elementType);
另见t.isArrayTypeAnnotation(node, opts)和t.assertArrayTypeAnnotation(node, opts)。
AST节点ArrayTypeAnnotation形状:
elementType:FlowType(必填)
别名: Flow ,FlowType (opens new window)
# arrowFunctionExpression
JavaScript
t.arrowFunctionExpression(params, body, async);
另见t.isArrowFunctionExpression(node, opts)和t.assertArrowFunctionExpression(node, opts)。
AST节点ArrowFunctionExpression形状:
params:Array<Identifier | Pattern | RestElement>(必填)body:BlockStatement | Expression(必填)async:boolean(默认:false)expression:boolean(必填)generator:(boolean默认值:false,从构建函数中排除)predicate:(DeclaredPredicate | InferredPredicate默认值:js,从构建函数中排除)returnType:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)typeParameters:(TypeParameterDeclaration | TSTypeParameterDeclaration | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Scopable , Function , BlockParent , FunctionParent , Expression ,Pureish (opens new window)
# 赋值表达式
JavaScript
t.assignmentExpression(operator, left, right);
另见t.isAssignmentExpression(node, opts)和t.assertAssignmentExpression(node, opts)。
AST节点AssignmentExpression形状:
operator:string(必填)left:LVal(必填)right:Expression(必填)
别名: Standardized ,Expression (opens new window)
# 赋值模式
JavaScript
t.assignmentPattern(left, right);
另见t.isAssignmentPattern(node, opts)和t.assertAssignmentPattern(node, opts)。
AST节点AssignmentPattern形状:
left:Identifier | ObjectPattern | ArrayPattern | MemberExpression | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression(必填)right:Expression(必填)decorators:(Array<Decorator>默认值:js,从构建函数中排除)optional:(boolean默认值:js,从构建函数中排除)typeAnnotation:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Pattern , PatternLike ,LVal (opens new window)
# 等待表达式
JavaScript
t.awaitExpression(argument);
另见t.isAwaitExpression(node, opts)和t.assertAwaitExpression(node, opts)。
AST节点AwaitExpression形状:
argument:Expression(必填)
别名:Standardized (opens new window) , Expression ,Terminatorless (opens new window)
# bigIntLiteral
JavaScript
t.bigIntLiteral(value);
另见t.isBigIntLiteral(node, opts)和t.assertBigIntLiteral(node, opts)。
AST节点BigIntLiteral形状:
value:string(必填)
别名:Standardized (opens new window) , Expression , Pureish , Literal ,Immutable (opens new window)
# 二元表达式
JavaScript
t.binaryExpression(operator, left, right);
另见t.isBinaryExpression(node, opts)和t.assertBinaryExpression(node, opts)。
AST节点BinaryExpression形状:
operator:"+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>"(必填)left:Expression | PrivateName(必填)right:Expression(必填)
别名:Standardized (opens new window) , Binary ,Expression (opens new window)
# 绑定表达式
JavaScript
t.bindExpression(object, callee);
另见t.isBindExpression(node, opts)和t.assertBindExpression(node, opts)。
AST节点BindExpression形状:
object:Expression(必填)callee:Expression(必填)
别名:Expression (opens new window)
# 块语句
JavaScript
t.blockStatement(body, directives);
另见t.isBlockStatement(node, opts)和t.assertBlockStatement(node, opts)。
AST节点BlockStatement形状:
body:Array<Statement>(必填)directives:Array<Directive>(默认:[])
别名:Standardized (opens new window) , Scopable , BlockParent , Block ,Statement (opens new window)
# 布尔文字
JavaScript
t.booleanLiteral(value);
另见t.isBooleanLiteral(node, opts)和t.assertBooleanLiteral(node, opts)。
AST节点BooleanLiteral形状:
value:boolean(必填)
别名:Standardized (opens new window) , Expression , Pureish , Literal ,Immutable (opens new window)
# booleanLiteralTypeAnnotation
JavaScript
t.booleanLiteralTypeAnnotation(value);
另见t.isBooleanLiteralTypeAnnotation(node, opts)和t.assertBooleanLiteralTypeAnnotation(node, opts)。
AST节点BooleanLiteralTypeAnnotation形状:
value:boolean(必填)
别名: Flow ,FlowType (opens new window)
# 布尔类型注解
JavaScript
t.booleanTypeAnnotation();
另见t.isBooleanTypeAnnotation(node, opts)和t.assertBooleanTypeAnnotation(node, opts)。
别名:Flow (opens new window) , FlowType ,FlowBaseAnnotation (opens new window)
# break语句
JavaScript
t.breakStatement(label);
另见t.isBreakStatement(node, opts)和t.assertBreakStatement(node, opts)。
AST节点BreakStatement形状:
label:Identifier(默认:js)
别名:Standardized (opens new window) , Statement , Terminatorless ,CompletionStatement (opens new window)
# callExpression
JavaScript
t.callExpression(callee, arguments);
另见t.isCallExpression(node, opts)和t.assertCallExpression(node, opts)。
AST节点CallExpression形状:
callee:Expression | Super | V8IntrinsicIdentifier(必填)arguments:Array<Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder>(必填)optional:(true | false默认值:js,从构建函数中排除)typeArguments:(TypeParameterInstantiation默认值:js,从构建函数中排除)typeParameters:(TSTypeParameterInstantiation默认值:js,从构建函数中排除)
别名: Standardized ,Expression (opens new window)
# 捕获子句
JavaScript
t.catchClause(param, body);
另见t.isCatchClause(node, opts)和t.assertCatchClause(node, opts)。
AST节点CatchClause形状:
param:Identifier | ArrayPattern | ObjectPattern(默认:js)body:BlockStatement(必填)
别名:Standardized (opens new window) , Scopable ,BlockParent (opens new window)
# 类AccessorProperty
JavaScript
t.classAccessorProperty(key, value, typeAnnotation, decorators, computed, static);
另见t.isClassAccessorProperty(node, opts)和t.assertClassAccessorProperty(node, opts)。
AST节点ClassAccessorProperty形状:
key:Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression | PrivateName(必填)value:Expression(默认:js)typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认:js)decorators:Array<Decorator>(默认:js)computed:boolean(默认:false)static:boolean(默认:false)abstract:(boolean默认值:js,从构建函数中排除)accessibility:("public" | "private" | "protected"默认值:js,从构建函数中排除)declare:(boolean默认值:js,从构建函数中排除)definite:(boolean默认值:js,从构建函数中排除)optional:(boolean默认值:js,从构建函数中排除)override:(boolean默认值:false,从构建函数中排除)readonly:(boolean默认值:js,从构建函数中排除)variance:(Variance默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Property ,Accessor (opens new window)
# 类主体
JavaScript
t.classBody(body);
另见t.isClassBody(node, opts)和t.assertClassBody(node, opts)。
AST节点ClassBody形状:
body:Array<ClassMethod | ClassPrivateMethod | ClassProperty | ClassPrivateProperty | ClassAccessorProperty | TSDeclareMethod | TSIndexSignature | StaticBlock>(必填)
别名:Standardized (opens new window)
# 类声明
JavaScript
t.classDeclaration(id, superClass, body, decorators);
另见t.isClassDeclaration(node, opts)和t.assertClassDeclaration(node, opts)。
AST节点ClassDeclaration形状:
id:Identifier(必填)superClass:Expression(默认:js)body:ClassBody(必填)decorators:Array<Decorator>(默认:js)abstract:(boolean默认值:js,从构建函数中排除)declare:(boolean默认值:js,从构建函数中排除)implements:(Array<TSExpressionWithTypeArguments | ClassImplements>默认值:js,从构建函数中排除)mixins:(InterfaceExtends默认值:js,从构建函数中排除)superTypeParameters:(TypeParameterInstantiation | TSTypeParameterInstantiation默认值:js,从构建函数中排除)typeParameters:(TypeParameterDeclaration | TSTypeParameterDeclaration | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Scopable , Class , Statement ,Declaration (opens new window)
# 类表达式
JavaScript
t.classExpression(id, superClass, body, decorators);
另见t.isClassExpression(node, opts)和t.assertClassExpression(node, opts)。
AST节点ClassExpression形状:
id:Identifier(默认:js)superClass:Expression(默认:js)body:ClassBody(必填)decorators:Array<Decorator>(默认:js)implements:(Array<TSExpressionWithTypeArguments | ClassImplements>默认值:js,从构建函数中排除)mixins:(InterfaceExtends默认值:js,从构建函数中排除)superTypeParameters:(TypeParameterInstantiation | TSTypeParameterInstantiation默认值:js,从构建函数中排除)typeParameters:(TypeParameterDeclaration | TSTypeParameterDeclaration | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Scopable , Class ,Expression (opens new window)
# 类实现
JavaScript
t.classImplements(id, typeParameters);
另见t.isClassImplements(node, opts)和t.assertClassImplements(node, opts)。
AST节点ClassImplements形状:
id:Identifier(必填)typeParameters:TypeParameterInstantiation(默认:js)
# 类方法
JavaScript
t.classMethod(kind, key, params, body, computed, static, generator, async);
另见t.isClassMethod(node, opts)和t.assertClassMethod(node, opts)。
AST节点ClassMethod形状:
kind:"get" | "set" | "method" | "constructor"(默认:'method')key: if computed thenExpressionelseIdentifier | Literal(必填)params:Array<Identifier | Pattern | RestElement | TSParameterProperty>(必填)body:BlockStatement(必填)computed:boolean(默认:false)static:boolean(默认:false)generator:boolean(默认:false)async:boolean(默认:false)abstract:(boolean默认值:js,从构建函数中排除)access:("public" | "private" | "protected"默认值:js,从构建函数中排除)accessibility:("public" | "private" | "protected"默认值:js,从构建函数中排除)decorators:(Array<Decorator>默认值:js,从构建函数中排除)optional:(boolean默认值:js,从构建函数中排除)override:(boolean默认值:false,从构建函数中排除)returnType:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)typeParameters:(TypeParameterDeclaration | TSTypeParameterDeclaration | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Function , Scopable , BlockParent , FunctionParent ,Method (opens new window)
# 类私有方法
JavaScript
t.classPrivateMethod(kind, key, params, body, static);
另见t.isClassPrivateMethod(node, opts)和t.assertClassPrivateMethod(node, opts)。
AST节点ClassPrivateMethod形状:
kind:"get" | "set" | "method"(默认:'method')key:PrivateName(必填)params:Array<Identifier | Pattern | RestElement | TSParameterProperty>(必填)body:BlockStatement(必填)static:boolean(默认:false)abstract:(boolean默认值:js,从构建函数中排除)access:("public" | "private" | "protected"默认值:js,从构建函数中排除)accessibility:("public" | "private" | "protected"默认值:js,从构建函数中排除)async:(boolean默认值:false,从构建函数中排除)computed: 'false' (默认值:false,从构建函数中排除)decorators:(Array<Decorator>默认值:js,从构建函数中排除)generator:(boolean默认值:false,从构建函数中排除)optional:(boolean默认值:js,从构建函数中排除)override:(boolean默认值:false,从构建函数中排除)returnType:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)typeParameters:(TypeParameterDeclaration | TSTypeParameterDeclaration | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Function , Scopable , BlockParent , FunctionParent , Method ,Private (opens new window)
# 类私有属性
JavaScript
t.classPrivateProperty(key, value, decorators, static);
另见t.isClassPrivateProperty(node, opts)和t.assertClassPrivateProperty(node, opts)。
AST节点ClassPrivateProperty形状:
key:PrivateName(必填)value:Expression(默认:js)decorators:Array<Decorator>(默认:js)static:boolean(默认:false)definite:(boolean默认值:js,从构建函数中排除)readonly:(boolean默认值:js,从构建函数中排除)typeAnnotation:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)variance:(Variance默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Property ,Private (opens new window)
# 类属性
JavaScript
t.classProperty(key, value, typeAnnotation, decorators, computed, static);
历史| | |
| :--- | :--- |
| | |
另见t.isClassProperty(node, opts)和t.assertClassProperty(node, opts)。
AST节点ClassProperty形状:
key:Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression(必填)value:Expression(默认:js)typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认:js)decorators:Array<Decorator>(默认:js)computed:boolean(默认:false)static:boolean(默认:false)abstract:(boolean默认值:js,从构建函数中排除)accessibility:("public" | "private" | "protected"默认值:js,从构建函数中排除)declare:(boolean默认值:js,从构建函数中排除)definite:(boolean默认值:js,从构建函数中排除)optional:(boolean默认值:js,从构建函数中排除)override:(boolean默认值:false,从构建函数中排除)readonly:(boolean默认值:js,从构建函数中排除)variance:(Variance默认值:js,从构建函数中排除)
别名: Standardized ,Property (opens new window)
# 条件表达式
JavaScript
t.conditionalExpression(test, consequent, alternate);
另见t.isConditionalExpression(node, opts)和t.assertConditionalExpression(node, opts)。
AST节点ConditionalExpression形状:
test:Expression(必填)consequent:Expression(必填)alternate:Expression(必填)
别名:Standardized (opens new window) , Expression ,Conditional (opens new window)
# continue语句
JavaScript
t.continueStatement(label);
另见t.isContinueStatement(node, opts)和t.assertContinueStatement(node, opts)。
AST节点ContinueStatement形状:
label:Identifier(默认:js)
别名:Standardized (opens new window) , Statement , Terminatorless ,CompletionStatement (opens new window)
# debuggerStatement
JavaScript
t.debuggerStatement();
另见t.isDebuggerStatement(node, opts)和t.assertDebuggerStatement(node, opts)。
别名: Standardized ,Statement (opens new window)
# 十进制文字
JavaScript
t.decimalLiteral(value);
另见t.isDecimalLiteral(node, opts)和t.assertDecimalLiteral(node, opts)。
AST节点DecimalLiteral形状:
value:string(必填)
别名:Expression (opens new window) , Pureish , Literal ,Immutable (opens new window)
# 声明类
JavaScript
t.declareClass(id, typeParameters, extends, body);
另见t.isDeclareClass(node, opts)和t.assertDeclareClass(node, opts)。
AST节点DeclareClass形状:
id:Identifier(必填)typeParameters:TypeParameterDeclaration(默认:js)extends:Array<InterfaceExtends>(默认:js)body:ObjectTypeAnnotation(必填)implements:(Array<ClassImplements>默认值:js,从构建函数中排除)mixins:(Array<InterfaceExtends>默认值:js,从构建函数中排除)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# declareExportAllDeclaration
JavaScript
t.declareExportAllDeclaration(source);
另见t.isDeclareExportAllDeclaration(node, opts)和t.assertDeclareExportAllDeclaration(node, opts)。
AST节点DeclareExportAllDeclaration形状:
source:StringLiteral(必填)exportKind:("type" | "value"默认值:js,从构建函数中排除)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# declareExportDeclaration
JavaScript
t.declareExportDeclaration(declaration, specifiers, source);
另见t.isDeclareExportDeclaration(node, opts)和t.assertDeclareExportDeclaration(node, opts)。
AST节点DeclareExportDeclaration形状:
declaration:Flow(默认:js)specifiers:Array<ExportSpecifier | ExportNamespaceSpecifier>(默认:js)source:StringLiteral(默认:js)default:(boolean默认值:js,从构建函数中排除)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# 声明函数
JavaScript
t.declareFunction(id);
另见t.isDeclareFunction(node, opts)和t.assertDeclareFunction(node, opts)。
AST节点DeclareFunction形状:
id:Identifier(必填)predicate:(DeclaredPredicate默认值:js,从构建函数中排除)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# 声明接口
JavaScript
t.declareInterface(id, typeParameters, extends, body);
另见t.isDeclareInterface(node, opts)和t.assertDeclareInterface(node, opts)。
AST节点DeclareInterface形状:
id:Identifier(必填)typeParameters:TypeParameterDeclaration(默认:js)extends:Array<InterfaceExtends>(默认:js)body:ObjectTypeAnnotation(必填)implements:(Array<ClassImplements>默认值:js,从构建函数中排除)mixins:(Array<InterfaceExtends>默认值:js,从构建函数中排除)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# 声明模块
JavaScript
t.declareModule(id, body, kind);
另见t.isDeclareModule(node, opts)和t.assertDeclareModule(node, opts)。
AST节点DeclareModule形状:
id:Identifier | StringLiteral(必填)body:BlockStatement(必填)kind:"CommonJS" | "ES"(默认:js)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# declareModuleExports
JavaScript
t.declareModuleExports(typeAnnotation);
另见t.isDeclareModuleExports(node, opts)和t.assertDeclareModuleExports(node, opts)。
AST节点DeclareModuleExports形状:
typeAnnotation:TypeAnnotation(必填)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# 声明不透明类型
JavaScript
t.declareOpaqueType(id, typeParameters, supertype);
另见t.isDeclareOpaqueType(node, opts)和t.assertDeclareOpaqueType(node, opts)。
AST节点DeclareOpaqueType形状:
id:Identifier(必填)typeParameters:TypeParameterDeclaration(默认:js)supertype:FlowType(默认:js)impltype:(FlowType默认值:js,从构建函数中排除)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# 声明类型别名
JavaScript
t.declareTypeAlias(id, typeParameters, right);
另见t.isDeclareTypeAlias(node, opts)和t.assertDeclareTypeAlias(node, opts)。
AST节点DeclareTypeAlias形状:
id:Identifier(必填)typeParameters:TypeParameterDeclaration(默认:js)right:FlowType(必填)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# 声明变量
JavaScript
t.declareVariable(id);
另见t.isDeclareVariable(node, opts)和t.assertDeclareVariable(node, opts)。
AST节点DeclareVariable形状:
id:Identifier(必填)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# 声明谓词
JavaScript
t.declaredPredicate(value);
另见t.isDeclaredPredicate(node, opts)和t.assertDeclaredPredicate(node, opts)。
AST节点DeclaredPredicate形状:
value:Flow(必填)
别名: Flow ,FlowPredicate (opens new window)
# 装饰器
JavaScript
t.decorator(expression);
另见t.isDecorator(node, opts)和t.assertDecorator(node, opts)。
AST节点Decorator形状:
expression:Expression(必填)
# 指令
JavaScript
t.directive(value);
另见t.isDirective(node, opts)和t.assertDirective(node, opts)。
AST节点Directive形状:
value:DirectiveLiteral(必填)
别名:Standardized (opens new window)
# 指令文字
JavaScript
t.directiveLiteral(value);
另见t.isDirectiveLiteral(node, opts)和t.assertDirectiveLiteral(node, opts)。
AST节点DirectiveLiteral形状:
value:string(必填)
别名:Standardized (opens new window)
# 做表达式
JavaScript
t.doExpression(body, async);
另见t.isDoExpression(node, opts)和t.assertDoExpression(node, opts)。
AST节点DoExpression形状:
body:BlockStatement(必填)async:boolean(默认:false)
别名:Expression (opens new window)
# doWhile语句
JavaScript
t.doWhileStatement(test, body);
另见t.isDoWhileStatement(node, opts)和t.assertDoWhileStatement(node, opts)。
AST节点DoWhileStatement形状:
test:Expression(必填)body:Statement(必填)
别名:Standardized (opens new window) , Statement , BlockParent , Loop , While ,Scopable (opens new window)
# 空语句
JavaScript
t.emptyStatement();
另见t.isEmptyStatement(node, opts)和t.assertEmptyStatement(node, opts)。
别名: Standardized ,Statement (opens new window)
# emptyTypeAnnotation
JavaScript
t.emptyTypeAnnotation();
另见t.isEmptyTypeAnnotation(node, opts)和t.assertEmptyTypeAnnotation(node, opts)。
别名:Flow (opens new window) , FlowType ,FlowBaseAnnotation (opens new window)
# 枚举布尔体
JavaScript
t.enumBooleanBody(members);
另见t.isEnumBooleanBody(node, opts)和t.assertEnumBooleanBody(node, opts)。
AST节点EnumBooleanBody形状:
members:Array<EnumBooleanMember>(必填)explicitType:boolean(必填)hasUnknownMembers:boolean(必填)
别名: Flow ,EnumBody (opens new window)
# 枚举布尔成员
JavaScript
t.enumBooleanMember(id);
另见t.isEnumBooleanMember(node, opts)和t.assertEnumBooleanMember(node, opts)。
AST节点EnumBooleanMember形状:
id:Identifier(必填)init:BooleanLiteral(必填)
别名: Flow ,EnumMember (opens new window)
# 枚举声明
JavaScript
t.enumDeclaration(id, body);
另见t.isEnumDeclaration(node, opts)和t.assertEnumDeclaration(node, opts)。
AST节点EnumDeclaration形状:
id:Identifier(必填)body:EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody(必填)
别名:Flow (opens new window) , Statement ,Declaration (opens new window)
# 枚举默认成员
JavaScript
t.enumDefaultedMember(id);
另见t.isEnumDefaultedMember(node, opts)和t.assertEnumDefaultedMember(node, opts)。
AST节点EnumDefaultedMember形状:
id:Identifier(必填)
别名: Flow ,EnumMember (opens new window)
# enumNumberBody
JavaScript
t.enumNumberBody(members);
另见t.isEnumNumberBody(node, opts)和t.assertEnumNumberBody(node, opts)。
AST节点EnumNumberBody形状:
members:Array<EnumNumberMember>(必填)explicitType:boolean(必填)hasUnknownMembers:boolean(必填)
别名: Flow ,EnumBody (opens new window)
# enumNumberMember
JavaScript
t.enumNumberMember(id, init);
另见t.isEnumNumberMember(node, opts)和t.assertEnumNumberMember(node, opts)。
AST节点EnumNumberMember形状:
id:Identifier(必填)init:NumericLiteral(必填)
别名: Flow ,EnumMember (opens new window)
# 枚举字符串体
JavaScript
t.enumStringBody(members);
另见t.isEnumStringBody(node, opts)和t.assertEnumStringBody(node, opts)。
AST节点EnumStringBody形状:
members:Array<EnumStringMember | EnumDefaultedMember>(必填)explicitType:boolean(必填)hasUnknownMembers:boolean(必填)
别名: Flow ,EnumBody (opens new window)
# 枚举字符串成员
JavaScript
t.enumStringMember(id, init);
另见t.isEnumStringMember(node, opts)和t.assertEnumStringMember(node, opts)。
AST节点EnumStringMember形状:
id:Identifier(必填)init:StringLiteral(必填)
别名: Flow ,EnumMember (opens new window)
# 枚举符号体
JavaScript
t.enumSymbolBody(members);
另见t.isEnumSymbolBody(node, opts)和t.assertEnumSymbolBody(node, opts)。
AST节点EnumSymbolBody形状:
members:Array<EnumDefaultedMember>(必填)hasUnknownMembers:boolean(必填)
别名: Flow ,EnumBody (opens new window)
# existsTypeAnnotation
JavaScript
t.existsTypeAnnotation();
另见t.isExistsTypeAnnotation(node, opts)和t.assertExistsTypeAnnotation(node, opts)。
别名: Flow ,FlowType (opens new window)
# exportAllDeclaration
JavaScript
t.exportAllDeclaration(source);
另见t.isExportAllDeclaration(node, opts)和t.assertExportAllDeclaration(node, opts)。
AST节点ExportAllDeclaration形状:
source:StringLiteral(必填)assertions:(Array<ImportAttribute>默认值:js,从构建函数中排除)exportKind:("type" | "value"默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Statement , Declaration , ImportOrExportDeclaration ,ExportDeclaration (opens new window)
# 导出默认声明
JavaScript
t.exportDefaultDeclaration(declaration);
另见t.isExportDefaultDeclaration(node, opts)和t.assertExportDefaultDeclaration(node, opts)。
AST节点ExportDefaultDeclaration形状:
declaration:TSDeclareFunction | FunctionDeclaration | ClassDeclaration | Expression(必填)exportKind:("value"默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Statement , Declaration , ImportOrExportDeclaration ,ExportDeclaration (opens new window)
# exportDefaultSpecifier
JavaScript
t.exportDefaultSpecifier(exported);
另见t.isExportDefaultSpecifier(node, opts)和t.assertExportDefaultSpecifier(node, opts)。
AST节点ExportDefaultSpecifier形状:
exported:Identifier(必填)
别名:ModuleSpecifier (opens new window)
# exportNamedDeclaration
JavaScript
t.exportNamedDeclaration(declaration, specifiers, source);
另见t.isExportNamedDeclaration(node, opts)和t.assertExportNamedDeclaration(node, opts)。
AST节点ExportNamedDeclaration形状:
declaration:Declaration(默认:js)specifiers:Array<ExportSpecifier | ExportDefaultSpecifier | ExportNamespaceSpecifier>(默认:[])source:StringLiteral(默认:js)assertions:(Array<ImportAttribute>默认值:js,从构建函数中排除)exportKind:("type" | "value"默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Statement , Declaration , ImportOrExportDeclaration ,ExportDeclaration (opens new window)
# exportNamespaceSpecifier
JavaScript
t.exportNamespaceSpecifier(exported);
另见t.isExportNamespaceSpecifier(node, opts)和t.assertExportNamespaceSpecifier(node, opts)。
AST节点ExportNamespaceSpecifier形状:
exported:Identifier(必填)
别名: Standardized ,ModuleSpecifier (opens new window)
# 导出说明符
JavaScript
t.exportSpecifier(local, exported);
另见t.isExportSpecifier(node, opts)和t.assertExportSpecifier(node, opts)。
AST节点ExportSpecifier形状:
local:Identifier(必填)exported:Identifier | StringLiteral(必填)exportKind:("type" | "value"默认值:js,从构建函数中排除)
别名: Standardized ,ModuleSpecifier (opens new window)
# 表达式语句
JavaScript
t.expressionStatement(expression);
另见t.isExpressionStatement(node, opts)和t.assertExpressionStatement(node, opts)。
AST节点ExpressionStatement形状:
expression:Expression(必填)
别名:Standardized (opens new window) , Statement ,ExpressionWrapper (opens new window)
# 文件
JavaScript
t.file(program, comments, tokens);
另见t.isFile(node, opts)和t.assertFile(node, opts)。
AST节点File形状:
program:Program(必填)comments:Array<CommentBlock | CommentLine>(默认:js)tokens:Array<any>(默认:js)
别名:Standardized (opens new window)
# forIn语句
JavaScript
t.forInStatement(left, right, body);
另见t.isForInStatement(node, opts)和t.assertForInStatement(node, opts)。
AST节点ForInStatement形状:
left:VariableDeclaration | LVal(必填)right:Expression(必填)body:Statement(必填)
别名:Standardized (opens new window) , Scopable , Statement , For , BlockParent , Loop ,ForXStatement (opens new window)
# forOf语句
JavaScript
t.forOfStatement(left, right, body, await);
另见t.isForOfStatement(node, opts)和t.assertForOfStatement(node, opts)。
AST节点ForOfStatement形状:
left:VariableDeclaration | LVal(必填)right:Expression(必填)body:Statement(必填)await:boolean(默认:false)
别名:Standardized (opens new window) , Scopable , Statement , For , BlockParent , Loop ,ForXStatement (opens new window)
# for语句
JavaScript
t.forStatement(init, test, update, body);
另见t.isForStatement(node, opts)和t.assertForStatement(node, opts)。
AST节点ForStatement形状:
init:VariableDeclaration | Expression(默认:js)test:Expression(默认:js)update:Expression(默认:js)body:Statement(必填)
别名:Standardized (opens new window) , Scopable , Statement , For , BlockParent ,Loop (opens new window)
# 函数声明
JavaScript
t.functionDeclaration(id, params, body, generator, async);
另见t.isFunctionDeclaration(node, opts)和t.assertFunctionDeclaration(node, opts)。
AST节点FunctionDeclaration形状:
id:Identifier(默认:js)params:Array<Identifier | Pattern | RestElement>(必填)body:BlockStatement(必填)generator:boolean(默认:false)async:boolean(默认:false)declare:(boolean默认值:js,从构建函数中排除)predicate:(DeclaredPredicate | InferredPredicate默认值:js,从构建函数中排除)returnType:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)typeParameters:(TypeParameterDeclaration | TSTypeParameterDeclaration | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Scopable , Function , BlockParent , FunctionParent , Statement , Pureish ,Declaration (opens new window)
# 函数表达式
JavaScript
t.functionExpression(id, params, body, generator, async);
另见t.isFunctionExpression(node, opts)和t.assertFunctionExpression(node, opts)。
AST节点FunctionExpression形状:
id:Identifier(默认:js)params:Array<Identifier | Pattern | RestElement>(必填)body:BlockStatement(必填)generator:boolean(默认:false)async:boolean(默认:false)predicate:(DeclaredPredicate | InferredPredicate默认值:js,从构建函数中排除)returnType:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)typeParameters:(TypeParameterDeclaration | TSTypeParameterDeclaration | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Scopable , Function , BlockParent , FunctionParent , Expression ,Pureish (opens new window)
# 函数类型注解
JavaScript
t.functionTypeAnnotation(typeParameters, params, rest, returnType);
另见t.isFunctionTypeAnnotation(node, opts)和t.assertFunctionTypeAnnotation(node, opts)。
AST节点FunctionTypeAnnotation形状:
typeParameters:TypeParameterDeclaration(默认:js)params:Array<FunctionTypeParam>(必填)rest:FunctionTypeParam(默认:js)returnType:FlowType(必填)this:(FunctionTypeParam默认值:js,从构建函数中排除)
别名: Flow ,FlowType (opens new window)
# 函数类型参数
JavaScript
t.functionTypeParam(name, typeAnnotation);
另见t.isFunctionTypeParam(node, opts)和t.assertFunctionTypeParam(node, opts)。
AST节点FunctionTypeParam形状:
name:Identifier(默认:js)typeAnnotation:FlowType(必填)optional:(boolean默认值:js,从构建函数中排除)
# genericTypeAnnotation
JavaScript
t.genericTypeAnnotation(id, typeParameters);
另见t.isGenericTypeAnnotation(node, opts)和t.assertGenericTypeAnnotation(node, opts)。
AST节点GenericTypeAnnotation形状:
id:Identifier | QualifiedTypeIdentifier(必填)typeParameters:TypeParameterInstantiation(默认:js)
别名: Flow ,FlowType (opens new window)
# 标识符
JavaScript
t.identifier(name);
另见t.isIdentifier(node, opts)和t.assertIdentifier(node, opts)。
AST节点Identifier形状:
name:string(必填)decorators:(Array<Decorator>默认值:js,从构建函数中排除)optional:(boolean默认值:js,从构建函数中排除)typeAnnotation:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Expression , PatternLike , LVal ,TSEntityName (opens new window)
# if语句
JavaScript
t.ifStatement(test, consequent, alternate);
另见t.isIfStatement(node, opts)和t.assertIfStatement(node, opts)。
AST节点IfStatement形状:
test:Expression(必填)consequent:Statement(必填)alternate:Statement(默认:js)
别名:Standardized (opens new window) , Statement ,Conditional (opens new window)
# 导入
JavaScript
t.import();
另见t.isImport(node, opts)和t.assertImport(node, opts)。
别名: Standardized ,Expression (opens new window)
# 导入属性
JavaScript
t.importAttribute(key, value);
另见t.isImportAttribute(node, opts)和t.assertImportAttribute(node, opts)。
AST节点ImportAttribute形状:
key:Identifier | StringLiteral(必填)value:StringLiteral(必填)
# 进口申报
JavaScript
t.importDeclaration(specifiers, source);
历史| | |
| :--- | :--- |
| | |
另见t.isImportDeclaration(node, opts)和t.assertImportDeclaration(node, opts)。
AST节点ImportDeclaration形状:
specifiers:Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>(必填)source:StringLiteral(必填)assertions:(Array<ImportAttribute>默认值:js,从构建函数中排除)importKind:("type" | "typeof" | "value"默认值:js,从构建函数中排除)module:(boolean默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , Statement , Declaration ,ImportOrExportDeclaration (opens new window)
# importDefaultSpecifier
JavaScript
t.importDefaultSpecifier(local);
另见t.isImportDefaultSpecifier(node, opts)和t.assertImportDefaultSpecifier(node, opts)。
AST节点ImportDefaultSpecifier形状:
local:Identifier(必填)
别名: Standardized ,ModuleSpecifier (opens new window)
# importNamespaceSpecifier
JavaScript
t.importNamespaceSpecifier(local);
另见t.isImportNamespaceSpecifier(node, opts)和t.assertImportNamespaceSpecifier(node, opts)。
AST节点ImportNamespaceSpecifier形状:
local:Identifier(必填)
别名: Standardized ,ModuleSpecifier (opens new window)
# 导入说明符
JavaScript
t.importSpecifier(local, imported);
另见t.isImportSpecifier(node, opts)和t.assertImportSpecifier(node, opts)。
AST节点ImportSpecifier形状:
local:Identifier(必填)imported:Identifier | StringLiteral(必填)importKind:("type" | "typeof" | "value"默认值:js,从构建函数中排除)
别名: Standardized ,ModuleSpecifier (opens new window)
# indexedAccessType
JavaScript
t.indexedAccessType(objectType, indexType);
另见t.isIndexedAccessType(node, opts)和t.assertIndexedAccessType(node, opts)。
AST节点IndexedAccessType形状:
objectType:FlowType(必填)indexType:FlowType(必填)
别名: Flow ,FlowType (opens new window)
# 推断谓词
JavaScript
t.inferredPredicate();
另见t.isInferredPredicate(node, opts)和t.assertInferredPredicate(node, opts)。
别名: Flow ,FlowPredicate (opens new window)
# 接口声明
JavaScript
t.interfaceDeclaration(id, typeParameters, extends, body);
另见t.isInterfaceDeclaration(node, opts)和t.assertInterfaceDeclaration(node, opts)。
AST节点InterfaceDeclaration形状:
id:Identifier(必填)typeParameters:TypeParameterDeclaration(默认:js)extends:Array<InterfaceExtends>(默认:js)body:ObjectTypeAnnotation(必填)implements:(Array<ClassImplements>默认值:js,从构建函数中排除)mixins:(Array<InterfaceExtends>默认值:js,从构建函数中排除)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# 接口扩展
JavaScript
t.interfaceExtends(id, typeParameters);
另见t.isInterfaceExtends(node, opts)和t.assertInterfaceExtends(node, opts)。
AST节点InterfaceExtends形状:
id:Identifier | QualifiedTypeIdentifier(必填)typeParameters:TypeParameterInstantiation(默认:js)
# 接口类型注解
JavaScript
t.interfaceTypeAnnotation(extends, body);
另见t.isInterfaceTypeAnnotation(node, opts)和t.assertInterfaceTypeAnnotation(node, opts)。
AST节点InterfaceTypeAnnotation形状:
extends:Array<InterfaceExtends>(默认:js)body:ObjectTypeAnnotation(必填)
别名: Flow ,FlowType (opens new window)
# 解释器指令
JavaScript
t.interpreterDirective(value);
另见t.isInterpreterDirective(node, opts)和t.assertInterpreterDirective(node, opts)。
AST节点InterpreterDirective形状:
value:string(必填)
别名:Standardized (opens new window)
# intersectionTypeAnnotation
JavaScript
t.intersectionTypeAnnotation(types);
另见t.isIntersectionTypeAnnotation(node, opts)和t.assertIntersectionTypeAnnotation(node, opts)。
AST节点IntersectionTypeAnnotation形状:
types:Array<FlowType>(必填)
别名: Flow ,FlowType (opens new window)
# jsx属性
JavaScript
t.jsxAttribute(name, value);
另见t.isJSXAttribute(node, opts)和t.assertJSXAttribute(node, opts)。
AST节点JSXAttribute形状:
name:JSXIdentifier | JSXNamespacedName(必填)value:JSXElement | JSXFragment | StringLiteral | JSXExpressionContainer(默认:js)
别名: JSX ,Immutable (opens new window)
# jsxClosingElement
JavaScript
t.jsxClosingElement(name);
另见t.isJSXClosingElement(node, opts)和t.assertJSXClosingElement(node, opts)。
AST节点JSXClosingElement形状:
name:JSXIdentifier | JSXMemberExpression | JSXNamespacedName(必填)
别名: JSX ,Immutable (opens new window)
# jsxClosingFragment
JavaScript
t.jsxClosingFragment();
另见t.isJSXClosingFragment(node, opts)和t.assertJSXClosingFragment(node, opts)。
别名: JSX ,Immutable (opens new window)
# jsx元素
JavaScript
t.jsxElement(openingElement, closingElement, children, selfClosing);
另见t.isJSXElement(node, opts)和t.assertJSXElement(node, opts)。
AST节点JSXElement形状:
openingElement:JSXOpeningElement(必填)closingElement:JSXClosingElement(默认:js)children:Array<JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment>(必填)selfClosing:boolean(默认:js)
别名:JSX (opens new window) , Immutable ,Expression (opens new window)
# jsxEmptyExpression
JavaScript
t.jsxEmptyExpression();
另见t.isJSXEmptyExpression(node, opts)和t.assertJSXEmptyExpression(node, opts)。
# jsxExpressionContainer
JavaScript
t.jsxExpressionContainer(expression);
另见t.isJSXExpressionContainer(node, opts)和t.assertJSXExpressionContainer(node, opts)。
AST节点JSXExpressionContainer形状:
expression:Expression | JSXEmptyExpression(必填)
别名: JSX ,Immutable (opens new window)
# jsx片段
JavaScript
t.jsxFragment(openingFragment, closingFragment, children);
另见t.isJSXFragment(node, opts)和t.assertJSXFragment(node, opts)。
AST节点JSXFragment形状:
openingFragment:JSXOpeningFragment(必填)closingFragment:JSXClosingFragment(必填)children:Array<JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment>(必填)
别名:JSX (opens new window) , Immutable ,Expression (opens new window)
# jsx标识符
JavaScript
t.jsxIdentifier(name);
另见t.isJSXIdentifier(node, opts)和t.assertJSXIdentifier(node, opts)。
AST节点JSXIdentifier形状:
name:string(必填)
# jsxMemberExpression
JavaScript
t.jsxMemberExpression(object, property);
另见t.isJSXMemberExpression(node, opts)和t.assertJSXMemberExpression(node, opts)。
AST节点JSXMemberExpression形状:
object:JSXMemberExpression | JSXIdentifier(必填)property:JSXIdentifier(必填)
# jsxNamespacedName
JavaScript
t.jsxNamespacedName(namespace, name);
另见t.isJSXNamespacedName(node, opts)和t.assertJSXNamespacedName(node, opts)。
AST节点JSXNamespacedName形状:
namespace:JSXIdentifier(必填)name:JSXIdentifier(必填)
# jsxOpeningElement
JavaScript
t.jsxOpeningElement(name, attributes, selfClosing);
另见t.isJSXOpeningElement(node, opts)和t.assertJSXOpeningElement(node, opts)。
AST节点JSXOpeningElement形状:
name:JSXIdentifier | JSXMemberExpression | JSXNamespacedName(必填)attributes:Array<JSXAttribute | JSXSpreadAttribute>(必填)selfClosing:boolean(默认:false)typeParameters:(TypeParameterInstantiation | TSTypeParameterInstantiation默认值:js,从构建函数中排除)
别名: JSX ,Immutable (opens new window)
# jsxOpeningFragment
JavaScript
t.jsxOpeningFragment();
另见t.isJSXOpeningFragment(node, opts)和t.assertJSXOpeningFragment(node, opts)。
别名: JSX ,Immutable (opens new window)
# jsxSpreadAttribute
JavaScript
t.jsxSpreadAttribute(argument);
另见t.isJSXSpreadAttribute(node, opts)和t.assertJSXSpreadAttribute(node, opts)。
AST节点JSXSpreadAttribute形状:
argument:Expression(必填)
# jsxSpreadChild
JavaScript
t.jsxSpreadChild(expression);
另见t.isJSXSpreadChild(node, opts)和t.assertJSXSpreadChild(node, opts)。
AST节点JSXSpreadChild形状:
expression:Expression(必填)
别名: JSX ,Immutable (opens new window)
# jsx文本
JavaScript
t.jsxText(value);
另见t.isJSXText(node, opts)和t.assertJSXText(node, opts)。
AST节点JSXText形状:
value:string(必填)
别名: JSX ,Immutable (opens new window)
# 标签声明
JavaScript
t.labeledStatement(label, body);
另见t.isLabeledStatement(node, opts)和t.assertLabeledStatement(node, opts)。
AST节点LabeledStatement形状:
label:Identifier(必填)body:Statement(必填)
别名: Standardized ,Statement (opens new window)
# 逻辑表达式
JavaScript
t.logicalExpression(operator, left, right);
另见t.isLogicalExpression(node, opts)和t.assertLogicalExpression(node, opts)。
AST节点LogicalExpression形状:
operator:"||" | "&&" | "??"(必填)left:Expression(必填)right:Expression(必填)
别名:Standardized (opens new window) , Binary ,Expression (opens new window)
# 成员表达式
JavaScript
t.memberExpression(object, property, computed, optional);
另见t.isMemberExpression(node, opts)和t.assertMemberExpression(node, opts)。
AST节点MemberExpression形状:
object:Expression | Super(必填)property: if computed thenExpressionelseIdentifier(必填)computed:boolean(默认:false)optional:true | false(默认:js)
别名:Standardized (opens new window) , Expression ,LVal (opens new window)
# 元属性
JavaScript
t.metaProperty(meta, property);
另见t.isMetaProperty(node, opts)和t.assertMetaProperty(node, opts)。
AST节点MetaProperty形状:
meta:Identifier(必填)property:Identifier(必填)
别名: Standardized ,Expression (opens new window)
# 混合类型注解
JavaScript
t.mixedTypeAnnotation();
另见t.isMixedTypeAnnotation(node, opts)和t.assertMixedTypeAnnotation(node, opts)。
别名:Flow (opens new window) , FlowType ,FlowBaseAnnotation (opens new window)
# 模块表达式
JavaScript
t.moduleExpression(body);
另见t.isModuleExpression(node, opts)和t.assertModuleExpression(node, opts)。
AST节点ModuleExpression形状:
body:Program(必填)
别名:Expression (opens new window)
# 新表达式
JavaScript
t.newExpression(callee, arguments);
另见t.isNewExpression(node, opts)和t.assertNewExpression(node, opts)。
AST节点NewExpression形状:
callee:Expression | Super | V8IntrinsicIdentifier(必填)arguments:Array<Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder>(必填)optional:(true | false默认值:js,从构建函数中排除)typeArguments:(TypeParameterInstantiation默认值:js,从构建函数中排除)typeParameters:(TSTypeParameterInstantiation默认值:js,从构建函数中排除)
别名: Standardized ,Expression (opens new window)
# 没有
JavaScript
t.noop();
另见t.isNoop(node, opts)和t.assertNoop(node, opts)。
别名:Miscellaneous (opens new window)
# 空文字
JavaScript
t.jsLiteral();
另见t.isNullLiteral(node, opts)和t.assertNullLiteral(node, opts)。
别名:Standardized (opens new window) , Expression , Pureish , Literal ,Immutable (opens new window)
# jsLiteralTypeAnnotation
JavaScript
t.jsLiteralTypeAnnotation();
另见t.isNullLiteralTypeAnnotation(node, opts)和t.assertNullLiteralTypeAnnotation(node, opts)。
别名:Flow (opens new window) , FlowType ,FlowBaseAnnotation (opens new window)
# jsableTypeAnnotation
JavaScript
t.jsableTypeAnnotation(typeAnnotation);
另见t.isNullableTypeAnnotation(node, opts)和t.assertNullableTypeAnnotation(node, opts)。
AST节点NullableTypeAnnotation形状:
typeAnnotation:FlowType(必填)
别名: Flow ,FlowType (opens new window)
# numberLiteralTypeAnnotation
JavaScript
t.numberLiteralTypeAnnotation(value);
另见t.isNumberLiteralTypeAnnotation(node, opts)和t.assertNumberLiteralTypeAnnotation(node, opts)。
AST节点NumberLiteralTypeAnnotation形状:
value:number(必填)
别名: Flow ,FlowType (opens new window)
# 数字类型注解
JavaScript
t.numberTypeAnnotation();
另见t.isNumberTypeAnnotation(node, opts)和t.assertNumberTypeAnnotation(node, opts)。
别名:Flow (opens new window) , FlowType ,FlowBaseAnnotation (opens new window)
# 数字字面量
JavaScript
t.numericLiteral(value);
另见t.isNumericLiteral(node, opts)和t.assertNumericLiteral(node, opts)。
AST节点NumericLiteral形状:
value:number(必填)
别名:Standardized (opens new window) , Expression , Pureish , Literal ,Immutable (opens new window)
# 对象表达式
JavaScript
t.objectExpression(properties);
另见t.isObjectExpression(node, opts)和t.assertObjectExpression(node, opts)。
AST节点ObjectExpression形状:
properties:Array<ObjectMethod | ObjectProperty | SpreadElement>(必填)
别名: Standardized ,Expression (opens new window)
# 对象方法
JavaScript
t.objectMethod(kind, key, params, body, computed, generator, async);
另见t.isObjectMethod(node, opts)和t.assertObjectMethod(node, opts)。
AST节点ObjectMethod形状:
kind:"method" | "get" | "set"(默认:'method')key: if computed thenExpressionelseIdentifier | Literal(必填)params:Array<Identifier | Pattern | RestElement>(必填)body:BlockStatement(必填)computed:boolean(默认:false)generator:boolean(默认:false)async:boolean(默认:false)decorators:(Array<Decorator>默认值:js,从构建函数中排除)returnType:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)typeParameters:(TypeParameterDeclaration | TSTypeParameterDeclaration | Noop默认值:js,从构建函数中排除)
Aliases: Standardized , UserWhitespacable , Function , Scopable , BlockParent , FunctionParent , Method , ObjectMember
# objectPattern
JavaScript
t.objectPattern(properties);
See also t.isObjectPattern(node, opts)and t.assertObjectPattern(node, opts).
AST Node ObjectPatternshape:
properties:Array<RestElement | ObjectProperty>(required)decorators:Array<Decorator>(default:js, excluded from builder function)optional:boolean(default:js, excluded from builder function)typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(default:js, excluded from builder function)
Aliases: Standardized , Pattern , PatternLike , LVal
# objectProperty
JavaScript
t.objectProperty(key, value, computed, shorthand, decorators);
See also t.isObjectProperty(node, opts)and t.assertObjectProperty(node, opts).
AST Node ObjectPropertyshape:
key: if computed thenExpressionelseIdentifier | Literal(required)value:Expression | PatternLike(required)computed:boolean(default:false)shorthand:boolean(default:false)decorators:Array<Decorator>(default:js)
Aliases: Standardized , UserWhitespacable , Property , ObjectMember
# objectTypeAnnotation
JavaScript
t.objectTypeAnnotation(properties, indexers, callProperties, internalSlots, exact);
See also t.isObjectTypeAnnotation(node, opts)and t.assertObjectTypeAnnotation(node, opts).
AST Node ObjectTypeAnnotationshape:
properties:Array<ObjectTypeProperty | ObjectTypeSpreadProperty>(required)indexers:Array<ObjectTypeIndexer>(default:[])callProperties:Array<ObjectTypeCallProperty>(default:[])internalSlots:Array<ObjectTypeInternalSlot>(default:[])exact:boolean(default:false)inexact:boolean(default:js, excluded from builder function)
Aliases: Flow , FlowType
# objectTypeCallProperty
JavaScript
t.objectTypeCallProperty(value);
See also t.isObjectTypeCallProperty(node, opts)and t.assertObjectTypeCallProperty(node, opts).
AST Node ObjectTypeCallPropertyshape:
value:FlowType(required)static:boolean(required)
Aliases: Flow , UserWhitespacable
# objectTypeIndexer
JavaScript
t.objectTypeIndexer(id, key, value, variance);
See also t.isObjectTypeIndexer(node, opts)and t.assertObjectTypeIndexer(node, opts).
AST Node ObjectTypeIndexershape:
id:Identifier(default:js)key:FlowType(required)value:FlowType(required)variance:Variance(default:js)static:boolean(required)
Aliases: Flow , UserWhitespacable
# objectTypeInternalSlot
JavaScript
t.objectTypeInternalSlot(id, value, optional, static, method);
See also t.isObjectTypeInternalSlot(node, opts)and t.assertObjectTypeInternalSlot(node, opts).
AST Node ObjectTypeInternalSlotshape:
id:Identifier(required)value:FlowType(required)optional:boolean(required)static:boolean(required)method:boolean(required)
Aliases: Flow , UserWhitespacable
# objectTypeProperty
JavaScript
t.objectTypeProperty(key, value, variance);
See also t.isObjectTypeProperty(node, opts)and t.assertObjectTypeProperty(node, opts).
AST Node ObjectTypePropertyshape:
key:Identifier | StringLiteral(required)value:FlowType(required)variance:Variance(default:js)kind:"init" | "get" | "set"(required)method:boolean(required)optional:boolean(required)proto:boolean(required)static:boolean(required)
Aliases: Flow , UserWhitespacable
# objectTypeSpreadProperty
JavaScript
t.objectTypeSpreadProperty(argument);
See also t.isObjectTypeSpreadProperty(node, opts)and t.assertObjectTypeSpreadProperty(node, opts).
AST Node ObjectTypeSpreadPropertyshape:
argument:FlowType(required)
Aliases: Flow , UserWhitespacable
# 不透明类型
JavaScript
t.opaqueType(id, typeParameters, supertype, impltype);
另见t.isOpaqueType(node, opts)和t.assertOpaqueType(node, opts)。
AST节点OpaqueType形状:
id:Identifier(必填)typeParameters:TypeParameterDeclaration(默认:js)supertype:FlowType(默认:js)impltype:FlowType(必填)
别名:Flow (opens new window) , FlowDeclaration , Statement ,Declaration (opens new window)
# optionalCallExpression
JavaScript
t.optionalCallExpression(callee, arguments, optional);
另见t.isOptionalCallExpression(node, opts)和t.assertOptionalCallExpression(node, opts)。
AST节点OptionalCallExpression形状:
callee:Expression(必填)arguments:Array<Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder>(必填)optional:boolean(必填)typeArguments:(TypeParameterInstantiation默认值:js,从构建函数中排除)typeParameters:(TSTypeParameterInstantiation默认值:js,从构建函数中排除)
别名: Standardized ,Expression (opens new window)
# 可选索引访问类型
JavaScript
t.optionalIndexedAccessType(objectType, indexType);
另见t.isOptionalIndexedAccessType(node, opts)和t.assertOptionalIndexedAccessType(node, opts)。
AST节点OptionalIndexedAccessType形状:
objectType:FlowType(必填)indexType:FlowType(必填)optional:boolean(必填)
别名: Flow ,FlowType (opens new window)
# 可选成员表达式
JavaScript
t.optionalMemberExpression(object, property, computed, optional);
另见t.isOptionalMemberExpression(node, opts)和t.assertOptionalMemberExpression(node, opts)。
AST节点OptionalMemberExpression形状:
object:Expression(必填)property:Expression | Identifier(必填)computed:boolean(默认:false)optional:boolean(必填)
别名: Standardized ,Expression (opens new window)
# 括号表达式
JavaScript
t.parenthesizedExpression(expression);
另见t.isParenthesizedExpression(node, opts)和t.assertParenthesizedExpression(node, opts)。
AST节点ParenthesizedExpression形状:
expression:Expression(必填)
别名:Standardized (opens new window) , Expression ,ExpressionWrapper (opens new window)
# pipelineBareFunction
JavaScript
t.pipelineBareFunction(callee);
另见t.isPipelineBareFunction(node, opts)和t.assertPipelineBareFunction(node, opts)。
AST节点PipelineBareFunction形状:
callee:Expression(必填)
别名:Expression (opens new window)
# pipelinePrimaryTopicReference
JavaScript
t.pipelinePrimaryTopicReference();
另见t.isPipelinePrimaryTopicReference(node, opts)和t.assertPipelinePrimaryTopicReference(node, opts)。
别名:Expression (opens new window)
# pipelineTopicExpression
JavaScript
t.pipelineTopicExpression(expression);
另见t.isPipelineTopicExpression(node, opts)和t.assertPipelineTopicExpression(node, opts)。
AST节点PipelineTopicExpression形状:
expression:Expression(必填)
别名:Expression (opens new window)
# 占位符
JavaScript
t.placeholder(expectedNode, name);
另见t.isPlaceholder(node, opts)和t.assertPlaceholder(node, opts)。
AST节点Placeholder形状:
expectedNode:"Identifier" | "StringLiteral" | "Expression" | "Statement" | "Declaration" | "BlockStatement" | "ClassBody" | "Pattern"(必填)name:Identifier(必填)
别名:Miscellaneous (opens new window)
# 私人姓名
JavaScript
t.privateName(id);
另见t.isPrivateName(node, opts)和t.assertPrivateName(node, opts)。
AST节点PrivateName形状:
id:Identifier(必填)
别名: Standardized ,Private (opens new window)
# 程序
JavaScript
t.program(body, directives, sourceType, interpreter);
另见t.isProgram(node, opts)和t.assertProgram(node, opts)。
AST节点Program形状:
body:Array<Statement>(必填)directives:Array<Directive>(默认:[])sourceType:"script" | "module"(默认:'script')interpreter:InterpreterDirective(默认:js)sourceFile:string(必填)
别名:Standardized (opens new window) , Scopable , BlockParent ,Block (opens new window)
# 合格类型标识符
JavaScript
t.qualifiedTypeIdentifier(id, qualification);
另见t.isQualifiedTypeIdentifier(node, opts)和t.assertQualifiedTypeIdentifier(node, opts)。
AST节点QualifiedTypeIdentifier形状:
id:Identifier(必填)qualification:Identifier | QualifiedTypeIdentifier(必填)
# 记录表达式
JavaScript
t.recordExpression(properties);
另见t.isRecordExpression(node, opts)和t.assertRecordExpression(node, opts)。
AST节点RecordExpression形状:
properties:Array<ObjectProperty | SpreadElement>(必填)
别名:Expression (opens new window)
# regExpLiteral
JavaScript
t.regExpLiteral(pattern, flags);
另见t.isRegExpLiteral(node, opts)和t.assertRegExpLiteral(node, opts)。
AST节点RegExpLiteral形状:
pattern:string(必填)flags:string(默认:'')
别名:Standardized (opens new window) , Expression , Pureish ,Literal (opens new window)
# 休息元素
JavaScript
t.restElement(argument);
另见t.isRestElement(node, opts)和t.assertRestElement(node, opts)。
AST节点RestElement形状:
argument:LVal(必填)decorators:(Array<Decorator>默认值:js,从构建函数中排除)optional:(boolean默认值:js,从构建函数中排除)typeAnnotation:(TypeAnnotation | TSTypeAnnotation | Noop默认值:js,从构建函数中排除)
别名:Standardized (opens new window) , LVal ,PatternLike (opens new window)
# 返回语句
JavaScript
t.returnStatement(argument);
另见t.isReturnStatement(node, opts)和t.assertReturnStatement(node, opts)。
AST节点ReturnStatement形状:
argument:Expression(默认:js)
别名:Standardized (opens new window) , Statement , Terminatorless ,CompletionStatement (opens new window)
# 序列表达式
JavaScript
t.sequenceExpression(expressions);
另见t.isSequenceExpression(node, opts)和t.assertSequenceExpression(node, opts)。
AST节点SequenceExpression形状:
expressions:Array<Expression>(必填)
别名: Standardized ,Expression (opens new window)
# 传播元素
JavaScript
t.spreadElement(argument);
另见t.isSpreadElement(node, opts)和t.assertSpreadElement(node, opts)。
AST节点SpreadElement形状:
argument:Expression(必填)
别名: Standardized ,UnaryLike (opens new window)
# 静态块
JavaScript
t.staticBlock(body);
另见t.isStaticBlock(node, opts)和t.assertStaticBlock(node, opts)。
AST节点StaticBlock形状:
body:Array<Statement>(必填)
别名:Standardized (opens new window) , Scopable , BlockParent ,FunctionParent (opens new window)
# 字符串文字
JavaScript
t.stringLiteral(value);
另见t.isStringLiteral(node, opts)和t.assertStringLiteral(node, opts)。
AST节点StringLiteral形状:
value:string(必填)
别名:Standardized (opens new window) , Expression , Pureish , Literal ,Immutable (opens new window)
# stringLiteralTypeAnnotation
JavaScript
t.stringLiteralTypeAnnotation(value);
另见t.isStringLiteralTypeAnnotation(node, opts)和t.assertStringLiteralTypeAnnotation(node, opts)。
AST节点StringLiteralTypeAnnotation形状:
value:string(必填)
别名: Flow ,FlowType (opens new window)
# stringTypeAnnotation
JavaScript
t.stringTypeAnnotation();
See also t.isStringTypeAnnotation(node, opts)and t.assertStringTypeAnnotation(node, opts).
Aliases: Flow , FlowType , FlowBaseAnnotation
# super
JavaScript
t.super();
See also t.isSuper(node, opts)and t.assertSuper(node, opts).
Aliases: Standardized , Expression
# switchCase
JavaScript
t.switchCase(test, consequent);
See also t.isSwitchCase(node, opts)and t.assertSwitchCase(node, opts).
AST Node SwitchCaseshape:
test:Expression(default:js)consequent:Array<Statement>(required)
Aliases: Standardized
# switchStatement
JavaScript
t.switchStatement(discriminant, cases);
See also t.isSwitchStatement(node, opts)and t.assertSwitchStatement(node, opts).
AST Node SwitchStatementshape:
discriminant:Expression(required)cases:Array<SwitchCase>(required)
Aliases: Standardized , Statement , BlockParent , Scopable
# symbolTypeAnnotation
JavaScript
t.symbolTypeAnnotation();
See also t.isSymbolTypeAnnotation(node, opts)and t.assertSymbolTypeAnnotation(node, opts).
Aliases: Flow , FlowType , FlowBaseAnnotation
# tsAnyKeyword
JavaScript
t.tsAnyKeyword();
See also t.isTSAnyKeyword(node, opts)and t.assertTSAnyKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsArrayType
JavaScript
t.tsArrayType(elementType);
See also t.isTSArrayType(node, opts)and t.assertTSArrayType(node, opts).
AST Node TSArrayTypeshape:
elementType:TSType(required)
Aliases: TypeScript , TSType
# tsAsExpression
JavaScript
t.tsAsExpression(expression, typeAnnotation);
See also t.isTSAsExpression(node, opts)and t.assertTSAsExpression(node, opts).
AST Node TSAsExpressionshape:
expression:Expression(required)typeAnnotation:TSType(required)
Aliases: TypeScript , Expression , LVal , PatternLike
# tsBigIntKeyword
JavaScript
t.tsBigIntKeyword();
See also t.isTSBigIntKeyword(node, opts)and t.assertTSBigIntKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsBooleanKeyword
JavaScript
t.tsBooleanKeyword();
See also t.isTSBooleanKeyword(node, opts)and t.assertTSBooleanKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsCallSignatureDeclaration
JavaScript
t.tsCallSignatureDeclaration(typeParameters, parameters, typeAnnotation);
See also t.isTSCallSignatureDeclaration(node, opts)and t.assertTSCallSignatureDeclaration(node, opts).
AST Node TSCallSignatureDeclarationshape:
typeParameters:TSTypeParameterDeclaration(default:js)parameters:Array<Identifier | RestElement>(required)typeAnnotation:TSTypeAnnotation(default:js)
Aliases: TypeScript , TSTypeElement
# tsConditionalType
JavaScript
t.tsConditionalType(checkType, extendsType, trueType, falseType);
See also t.isTSConditionalType(node, opts)and t.assertTSConditionalType(node, opts).
AST Node TSConditionalTypeshape:
checkType:TSType(required)extendsType:TSType(required)trueType:TSType(required)falseType:TSType(required)
Aliases: TypeScript , TSType
# tsConstructSignatureDeclaration
JavaScript
t.tsConstructSignatureDeclaration(typeParameters, parameters, typeAnnotation);
See also t.isTSConstructSignatureDeclaration(node, opts)and t.assertTSConstructSignatureDeclaration(node, opts).
AST Node TSConstructSignatureDeclarationshape:
typeParameters:TSTypeParameterDeclaration(default:js)parameters:Array<Identifier | RestElement>(required)typeAnnotation:TSTypeAnnotation(default:js)
Aliases: TypeScript , TSTypeElement
# tsConstructorType
JavaScript
t.tsConstructorType(typeParameters, parameters, typeAnnotation);
See also t.isTSConstructorType(node, opts)and t.assertTSConstructorType(node, opts).
AST Node TSConstructorTypeshape:
typeParameters:TSTypeParameterDeclaration(default:js)parameters:Array<Identifier | RestElement>(required)typeAnnotation:TSTypeAnnotation(default:js)abstract:boolean(default:js, excluded from builder function)
Aliases: TypeScript , TSType
# tsDeclareFunction
JavaScript
t.tsDeclareFunction(id, typeParameters, params, returnType);
See also t.isTSDeclareFunction(node, opts)and t.assertTSDeclareFunction(node, opts).
AST Node TSDeclareFunctionshape:
id:Identifier(default:js)typeParameters:TSTypeParameterDeclaration | Noop(default:js)params:Array<Identifier | Pattern | RestElement>(required)returnType:TSTypeAnnotation | Noop(default:js)async:boolean(default:false, excluded from builder function)declare:boolean(default:js, excluded from builder function)generator:boolean(default:false, excluded from builder function)
Aliases: TypeScript , Statement , Declaration
# tsDeclareMethod
JavaScript
t.tsDeclareMethod(decorators, key, typeParameters, params, returnType);
See also t.isTSDeclareMethod(node, opts)and t.assertTSDeclareMethod(node, opts).
AST Node TSDeclareMethodshape:
decorators:Array<Decorator>(default:js)key:Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression(required)typeParameters:TSTypeParameterDeclaration | Noop(default:js)params:Array<Identifier | Pattern | RestElement | TSParameterProperty>(required)returnType:TSTypeAnnotation | Noop(default:js)abstract:boolean(default:js, excluded from builder function)access:"public" | "private" | "protected"(default:js, excluded from builder function)accessibility:"public" | "private" | "protected"(default:js, excluded from builder function)async:boolean(default:false, excluded from builder function)computed:boolean(default:false, excluded from builder function)generator:boolean(default:false, excluded from builder function)kind:"get" | "set" | "method" | "constructor"(default:'method', excluded from builder function)optional:boolean(default:js, excluded from builder function)override:boolean(default:false, excluded from builder function)static:boolean(default:false, excluded from builder function)
Aliases: TypeScript
# tsEnumDeclaration
JavaScript
t.tsEnumDeclaration(id, members);
See also t.isTSEnumDeclaration(node, opts)and t.assertTSEnumDeclaration(node, opts).
AST Node TSEnumDeclarationshape:
id:Identifier(required)members:Array<TSEnumMember>(required)const:boolean(default:js, excluded from builder function)declare:boolean(default:js, excluded from builder function)initializer:Expression(default:js, excluded from builder function)
Aliases: TypeScript , Statement , Declaration
# tsEnumMember
JavaScript
t.tsEnumMember(id, initializer);
See also t.isTSEnumMember(node, opts)and t.assertTSEnumMember(node, opts).
AST Node TSEnumMembershape:
id:Identifier | StringLiteral(required)initializer:Expression(default:js)
Aliases: TypeScript
# tsExportAssignment
JavaScript
t.tsExportAssignment(expression);
See also t.isTSExportAssignment(node, opts)and t.assertTSExportAssignment(node, opts).
AST Node TSExportAssignmentshape:
expression:Expression(required)
Aliases: TypeScript , Statement
# tsExpressionWithTypeArguments
JavaScript
t.tsExpressionWithTypeArguments(expression, typeParameters);
See also t.isTSExpressionWithTypeArguments(node, opts)and t.assertTSExpressionWithTypeArguments(node, opts).
AST Node TSExpressionWithTypeArgumentsshape:
expression:TSEntityName(required)typeParameters:TSTypeParameterInstantiation(default:js)
Aliases: TypeScript , TSType
# tsExternalModuleReference
JavaScript
t.tsExternalModuleReference(expression);
See also t.isTSExternalModuleReference(node, opts)and t.assertTSExternalModuleReference(node, opts).
AST Node TSExternalModuleReferenceshape:
expression:StringLiteral(required)
Aliases: TypeScript
# tsFunctionType
JavaScript
t.tsFunctionType(typeParameters, parameters, typeAnnotation);
See also t.isTSFunctionType(node, opts)and t.assertTSFunctionType(node, opts).
AST Node TSFunctionTypeshape:
typeParameters:TSTypeParameterDeclaration(default:js)parameters:Array<Identifier | RestElement>(required)typeAnnotation:TSTypeAnnotation(default:js)
Aliases: TypeScript , TSType
# tsImportEqualsDeclaration
JavaScript
t.tsImportEqualsDeclaration(id, moduleReference);
See also t.isTSImportEqualsDeclaration(node, opts)and t.assertTSImportEqualsDeclaration(node, opts).
AST Node TSImportEqualsDeclarationshape:
id:Identifier(required)moduleReference:TSEntityName | TSExternalModuleReference(required)importKind:"type" | "value"(default:js, excluded from builder function)isExport:boolean(required)
Aliases: TypeScript , Statement
# tsImportType
JavaScript
t.tsImportType(argument, qualifier, typeParameters);
See also t.isTSImportType(node, opts)and t.assertTSImportType(node, opts).
AST Node TSImportTypeshape:
argument:StringLiteral(required)qualifier:TSEntityName(default:js)typeParameters:TSTypeParameterInstantiation(default:js)
Aliases: TypeScript , TSType
# tsIndexSignature
JavaScript
t.tsIndexSignature(parameters, typeAnnotation);
See also t.isTSIndexSignature(node, opts)and t.assertTSIndexSignature(node, opts).
AST Node TSIndexSignatureshape:
parameters:Array<Identifier>(required)typeAnnotation:TSTypeAnnotation(default:js)readonly:boolean(default:js, excluded from builder function)static:boolean(default:js, excluded from builder function)
Aliases: TypeScript , TSTypeElement
# tsIndexedAccessType
JavaScript
t.tsIndexedAccessType(objectType, indexType);
See also t.isTSIndexedAccessType(node, opts)and t.assertTSIndexedAccessType(node, opts).
AST Node TSIndexedAccessTypeshape:
objectType:TSType(required)indexType:TSType(required)
Aliases: TypeScript , TSType
# tsInferType
JavaScript
t.tsInferType(typeParameter);
See also t.isTSInferType(node, opts)and t.assertTSInferType(node, opts).
AST Node TSInferTypeshape:
typeParameter:TSTypeParameter(required)
Aliases: TypeScript , TSType
# tsInstantiationExpression
JavaScript
t.tsInstantiationExpression(expression, typeParameters);
See also t.isTSInstantiationExpression(node, opts)and t.assertTSInstantiationExpression(node, opts).
AST Node TSInstantiationExpressionshape:
expression:Expression(required)typeParameters:TSTypeParameterInstantiation(default:js)
Aliases: TypeScript , Expression
# tsInterfaceBody
JavaScript
t.tsInterfaceBody(body);
See also t.isTSInterfaceBody(node, opts)and t.assertTSInterfaceBody(node, opts).
AST Node TSInterfaceBodyshape:
body:Array<TSTypeElement>(required)
Aliases: TypeScript
# tsInterfaceDeclaration
JavaScript
t.tsInterfaceDeclaration(id, typeParameters, extends, body);
See also t.isTSInterfaceDeclaration(node, opts)and t.assertTSInterfaceDeclaration(node, opts).
AST Node TSInterfaceDeclarationshape:
id:Identifier(required)typeParameters:TSTypeParameterDeclaration(default:js)extends:Array<TSExpressionWithTypeArguments>(default:js)body:TSInterfaceBody(required)declare:boolean(default:js, excluded from builder function)
Aliases: TypeScript , Statement , Declaration
# tsIntersectionType
JavaScript
t.tsIntersectionType(types);
See also t.isTSIntersectionType(node, opts)and t.assertTSIntersectionType(node, opts).
AST Node TSIntersectionTypeshape:
types:Array<TSType>(required)
Aliases: TypeScript , TSType
# tsIntrinsicKeyword
JavaScript
t.tsIntrinsicKeyword();
See also t.isTSIntrinsicKeyword(node, opts)and t.assertTSIntrinsicKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsLiteralType
JavaScript
t.tsLiteralType(literal);
See also t.isTSLiteralType(node, opts)and t.assertTSLiteralType(node, opts).
AST Node TSLiteralTypeshape:
literal:NumericLiteral | StringLiteral | BooleanLiteral | BigIntLiteral | TemplateLiteral | UnaryExpression(required)
Aliases: TypeScript , TSType , TSBaseType
# tsMappedType
JavaScript
t.tsMappedType(typeParameter, typeAnnotation, nameType);
See also t.isTSMappedType(node, opts)and t.assertTSMappedType(node, opts).
AST Node TSMappedTypeshape:
typeParameter:TSTypeParameter(required)typeAnnotation:TSType(default:js)nameType:TSType(default:js)optional:true | false | "+" | "-"(default:js, excluded from builder function)readonly:true | false | "+" | "-"(default:js, excluded from builder function)
Aliases: TypeScript , TSType
# tsMethodSignature
JavaScript
t.tsMethodSignature(key, typeParameters, parameters, typeAnnotation);
See also t.isTSMethodSignature(node, opts)and t.assertTSMethodSignature(node, opts).
AST Node TSMethodSignatureshape:
key:Expression(required)typeParameters:TSTypeParameterDeclaration(default:js)parameters:Array<Identifier | RestElement>(required)typeAnnotation:TSTypeAnnotation(default:js)computed:boolean(default:false, excluded from builder function)kind:"method" | "get" | "set"(required)optional:boolean(default:js, excluded from builder function)
Aliases: TypeScript , TSTypeElement
# tsModuleBlock
JavaScript
t.tsModuleBlock(body);
See also t.isTSModuleBlock(node, opts)and t.assertTSModuleBlock(node, opts).
AST Node TSModuleBlockshape:
body:Array<Statement>(required)
Aliases: TypeScript , Scopable , Block , BlockParent , FunctionParent
# tsModuleDeclaration
JavaScript
t.tsModuleDeclaration(id, body);
See also t.isTSModuleDeclaration(node, opts)and t.assertTSModuleDeclaration(node, opts).
AST Node TSModuleDeclarationshape:
id:Identifier | StringLiteral(required)body:TSModuleBlock | TSModuleDeclaration(required)declare:boolean(default:js, excluded from builder function)global:boolean(default:js, excluded from builder function)
Aliases: TypeScript , Statement , Declaration
# tsNamedTupleMember
JavaScript
t.tsNamedTupleMember(label, elementType, optional);
See also t.isTSNamedTupleMember(node, opts)and t.assertTSNamedTupleMember(node, opts).
AST Node TSNamedTupleMembershape:
label:Identifier(required)elementType:TSType(required)optional:boolean(default:false)
Aliases: TypeScript
# tsNamespaceExportDeclaration
JavaScript
t.tsNamespaceExportDeclaration(id);
See also t.isTSNamespaceExportDeclaration(node, opts)and t.assertTSNamespaceExportDeclaration(node, opts).
AST Node TSNamespaceExportDeclarationshape:
id:Identifier(required)
Aliases: TypeScript , Statement
# tsNeverKeyword
JavaScript
t.tsNeverKeyword();
See also t.isTSNeverKeyword(node, opts)and t.assertTSNeverKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsNonNullExpression
JavaScript
t.tsNonNullExpression(expression);
See also t.isTSNonNullExpression(node, opts)and t.assertTSNonNullExpression(node, opts).
AST Node TSNonNullExpressionshape:
expression:Expression(required)
Aliases: TypeScript , Expression , LVal , PatternLike
# tsNullKeyword
JavaScript
t.tsNullKeyword();
See also t.isTSNullKeyword(node, opts)and t.assertTSNullKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsNumberKeyword
JavaScript
t.tsNumberKeyword();
See also t.isTSNumberKeyword(node, opts)and t.assertTSNumberKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsObjectKeyword
JavaScript
t.tsObjectKeyword();
See also t.isTSObjectKeyword(node, opts)and t.assertTSObjectKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsOptionalType
JavaScript
t.tsOptionalType(typeAnnotation);
See also t.isTSOptionalType(node, opts)and t.assertTSOptionalType(node, opts).
AST Node TSOptionalTypeshape:
typeAnnotation:TSType(required)
Aliases: TypeScript , TSType
# tsParameterProperty
JavaScript
t.tsParameterProperty(parameter);
See also t.isTSParameterProperty(node, opts)and t.assertTSParameterProperty(node, opts).
AST Node TSParameterPropertyshape:
parameter:Identifier | AssignmentPattern(required)accessibility:"public" | "private" | "protected"(default:js, excluded from builder function)decorators:Array<Decorator>(default:js, excluded from builder function)override:boolean(default:js, excluded from builder function)readonly:boolean(default:js, excluded from builder function)
Aliases: TypeScript , LVal
# tsParenthesizedType
JavaScript
t.tsParenthesizedType(typeAnnotation);
See also t.isTSParenthesizedType(node, opts)and t.assertTSParenthesizedType(node, opts).
AST Node TSParenthesizedTypeshape:
typeAnnotation:TSType(required)
Aliases: TypeScript , TSType
# tsPropertySignature
JavaScript
t.tsPropertySignature(key, typeAnnotation, initializer);
另见t.isTSPropertySignature(node, opts)和t.assertTSPropertySignature(node, opts)。
AST节点TSPropertySignature形状:
key:Expression(必填)typeAnnotation:TSTypeAnnotation(默认:js)initializer:Expression(默认:js)computed:(boolean默认值:false,从构建函数中排除)kind:"get" | "set"(必填)optional:(boolean默认值:js,从构建函数中排除)readonly:(boolean默认值:js,从构建函数中排除)
别名: TypeScript ,TSTypeElement (opens new window)
# ts合格名称
JavaScript
t.tsQualifiedName(left, right);
另见t.isTSQualifiedName(node, opts)和t.assertTSQualifiedName(node, opts)。
AST节点TSQualifiedName形状:
left:TSEntityName(必填)right:Identifier(必填)
别名: TypeScript ,TSEntityName (opens new window)
# tsRestType
JavaScript
t.tsRestType(typeAnnotation);
另见t.isTSRestType(node, opts)和t.assertTSRestType(node, opts)。
AST节点TSRestType形状:
typeAnnotation:TSType(必填)
别名: TypeScript ,TSType (opens new window)
# tsSatisfiesExpression
JavaScript
t.tsSatisfiesExpression(expression, typeAnnotation);
历史| | | | :--- | :--- | | ``| |
另见t.isTSSatisfiesExpression(node, opts)和t.assertTSSatisfiesExpression(node, opts)。
AST节点TSSatisfiesExpression形状:
expression:Expression(必填)typeAnnotation:TSType(必填)
别名:TypeScript (opens new window) , Expression , LVal ,PatternLike (opens new window)
# tsString关键字
JavaScript
t.tsStringKeyword();
另见t.isTSStringKeyword(node, opts)和t.assertTSStringKeyword(node, opts)。
别名:TypeScript (opens new window) , TSType ,TSBaseType (opens new window)
# ts符号关键字
JavaScript
t.tsSymbolKeyword();
另见t.isTSSymbolKeyword(node, opts)和t.assertTSSymbolKeyword(node, opts)。
别名:TypeScript (opens new window) , TSType ,TSBaseType (opens new window)
# tsThisType
JavaScript
t.tsThisType();
另见t.isTSThisType(node, opts)和t.assertTSThisType(node, opts)。
别名:TypeScript (opens new window) , TSType ,TSBaseType (opens new window)
# ts元组类型
JavaScript
t.tsTupleType(elementTypes);
另见t.isTSTupleType(node, opts)和t.assertTSTupleType(node, opts)。
AST节点TSTupleType形状:
elementTypes:Array<TSType | TSNamedTupleMember>(必填)
别名: TypeScript ,TSType (opens new window)
# tsTypeAliasDeclaration
JavaScript
t.tsTypeAliasDeclaration(id, typeParameters, typeAnnotation);
另见t.isTSTypeAliasDeclaration(node, opts)和t.assertTSTypeAliasDeclaration(node, opts)。
AST节点TSTypeAliasDeclaration形状:
id:Identifier(必填)typeParameters:TSTypeParameterDeclaration(默认:js)typeAnnotation:TSType(必填)declare:(boolean默认值:js,从构建函数中排除)
别名:TypeScript (opens new window) , Statement ,Declaration (opens new window)
# tsTypeAnnotation
JavaScript
t.tsTypeAnnotation(typeAnnotation);
另见t.isTSTypeAnnotation(node, opts)和t.assertTSTypeAnnotation(node, opts)。
AST节点TSTypeAnnotation形状:
typeAnnotation:TSType(必填)
别名:TypeScript (opens new window)
# tsTypeAssertion
JavaScript
t.tsTypeAssertion(typeAnnotation, expression);
另见t.isTSTypeAssertion(node, opts)和t.assertTSTypeAssertion(node, opts)。
AST节点TSTypeAssertion形状:
typeAnnotation:TSType(必填)expression:Expression(必填)
别名:TypeScript (opens new window) , Expression , LVal ,PatternLike (opens new window)
# tsType文字
JavaScript
t.tsTypeLiteral(members);
另见t.isTSTypeLiteral(node, opts)和t.assertTSTypeLiteral(node, opts)。
AST节点TSTypeLiteral形状:
members:Array<TSTypeElement>(必填)
别名: TypeScript ,TSType (opens new window)
# tsTypeOperator
JavaScript
t.tsTypeOperator(typeAnnotation);
See also t.isTSTypeOperator(node, opts)and t.assertTSTypeOperator(node, opts).
AST Node TSTypeOperatorshape:
typeAnnotation:TSType(required)operator:string(required)
Aliases: TypeScript , TSType
# tsTypeParameter
JavaScript
t.tsTypeParameter(constraint, default, name);
History| | |
| :--- | :--- |
| | |
See also t.isTSTypeParameter(node, opts)and t.assertTSTypeParameter(node, opts).
AST Node TSTypeParametershape:
constraint:TSType(default:js)default:TSType(default:js)name:string(required)const:boolean(default:js, excluded from builder function)in:boolean(default:js, excluded from builder function)out:boolean(default:js, excluded from builder function)
Aliases: TypeScript
# tsTypeParameterDeclaration
JavaScript
t.tsTypeParameterDeclaration(params);
See also t.isTSTypeParameterDeclaration(node, opts)and t.assertTSTypeParameterDeclaration(node, opts).
AST Node TSTypeParameterDeclarationshape:
params:Array<TSTypeParameter>(required)
Aliases: TypeScript
# tsTypeParameterInstantiation
JavaScript
t.tsTypeParameterInstantiation(params);
See also t.isTSTypeParameterInstantiation(node, opts)and t.assertTSTypeParameterInstantiation(node, opts).
AST Node TSTypeParameterInstantiationshape:
params:Array<TSType>(required)
Aliases: TypeScript
# tsTypePredicate
JavaScript
t.tsTypePredicate(parameterName, typeAnnotation, asserts);
See also t.isTSTypePredicate(node, opts)and t.assertTSTypePredicate(node, opts).
AST Node TSTypePredicateshape:
parameterName:Identifier | TSThisType(required)typeAnnotation:TSTypeAnnotation(default:js)asserts:boolean(default:js)
Aliases: TypeScript , TSType
# tsTypeQuery
JavaScript
t.tsTypeQuery(exprName, typeParameters);
See also t.isTSTypeQuery(node, opts)and t.assertTSTypeQuery(node, opts).
AST Node TSTypeQueryshape:
exprName:TSEntityName | TSImportType(required)typeParameters:TSTypeParameterInstantiation(default:js)
Aliases: TypeScript , TSType
# tsTypeReference
JavaScript
t.tsTypeReference(typeName, typeParameters);
See also t.isTSTypeReference(node, opts)and t.assertTSTypeReference(node, opts).
AST Node TSTypeReferenceshape:
typeName:TSEntityName(required)typeParameters:TSTypeParameterInstantiation(default:js)
Aliases: TypeScript , TSType
# tsUndefinedKeyword
JavaScript
t.tsUndefinedKeyword();
See also t.isTSUndefinedKeyword(node, opts)and t.assertTSUndefinedKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsUnionType
JavaScript
t.tsUnionType(types);
See also t.isTSUnionType(node, opts)and t.assertTSUnionType(node, opts).
AST Node TSUnionTypeshape:
types:Array<TSType>(required)
Aliases: TypeScript , TSType
# tsUnknownKeyword
JavaScript
t.tsUnknownKeyword();
See also t.isTSUnknownKeyword(node, opts)and t.assertTSUnknownKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# tsVoidKeyword
JavaScript
t.tsVoidKeyword();
See also t.isTSVoidKeyword(node, opts)and t.assertTSVoidKeyword(node, opts).
Aliases: TypeScript , TSType , TSBaseType
# taggedTemplateExpression
JavaScript
t.taggedTemplateExpression(tag, quasi);
See also t.isTaggedTemplateExpression(node, opts)and t.assertTaggedTemplateExpression(node, opts).
AST Node TaggedTemplateExpressionshape:
tag:Expression(required)quasi:TemplateLiteral(required)typeParameters:TypeParameterInstantiation | TSTypeParameterInstantiation(default:js, excluded from builder function)
Aliases: Standardized , Expression
# templateElement
JavaScript
t.templateElement(value, tail);
See also t.isTemplateElement(node, opts)and t.assertTemplateElement(node, opts).
AST Node TemplateElementshape:
value:{ raw: string, cooked?: string }(required)tail:boolean(default:false)
Aliases: Standardized
# templateLiteral
JavaScript
t.templateLiteral(quasis, expressions);
See also t.isTemplateLiteral(node, opts)and t.assertTemplateLiteral(node, opts).
AST Node TemplateLiteralshape:
quasis:Array<TemplateElement>(required)expressions:Array<Expression | TSType>(required)
Aliases: Standardized , Expression , Literal
# thisExpression
JavaScript
t.thisExpression();
See also t.isThisExpression(node, opts)and t.assertThisExpression(node, opts).
Aliases: Standardized , Expression
# thisTypeAnnotation
JavaScript
t.thisTypeAnnotation();
See also t.isThisTypeAnnotation(node, opts)and t.assertThisTypeAnnotation(node, opts).
Aliases: Flow , FlowType , FlowBaseAnnotation
# throwStatement
JavaScript
t.throwStatement(argument);
See also t.isThrowStatement(node, opts)and t.assertThrowStatement(node, opts).
AST Node ThrowStatementshape:
argument:Expression(required)
Aliases: Standardized , Statement , Terminatorless , CompletionStatement
# topicReference
JavaScript
t.topicReference();
See also t.isTopicReference(node, opts)and t.assertTopicReference(node, opts).
Aliases: Expression
# tryStatement
JavaScript
t.tryStatement(block, handler, finalizer);
See also t.isTryStatement(node, opts)and t.assertTryStatement(node, opts).
AST Node TryStatementshape:
block:BlockStatement(required)handler:CatchClause(default:js)finalizer:BlockStatement(default:js)
Aliases: Standardized , Statement
# tupleExpression
JavaScript
t.tupleExpression(elements);
See also t.isTupleExpression(node, opts)and t.assertTupleExpression(node, opts).
AST Node TupleExpressionshape:
elements:Array<Expression | SpreadElement>(default:[])
Aliases: Expression
# tupleTypeAnnotation
JavaScript
t.tupleTypeAnnotation(types);
See also t.isTupleTypeAnnotation(node, opts)and t.assertTupleTypeAnnotation(node, opts).
AST Node TupleTypeAnnotationshape:
types:Array<FlowType>(required)
Aliases: Flow , FlowType
# typeAlias
JavaScript
t.typeAlias(id, typeParameters, right);
See also t.isTypeAlias(node, opts)and t.assertTypeAlias(node, opts).
AST Node TypeAliasshape:
id:Identifier(required)typeParameters:TypeParameterDeclaration(default:js)right:FlowType(required)
Aliases: Flow , FlowDeclaration , Statement , Declaration
# typeAnnotation
JavaScript
t.typeAnnotation(typeAnnotation);
See also t.isTypeAnnotation(node, opts)and t.assertTypeAnnotation(node, opts).
AST Node TypeAnnotationshape:
typeAnnotation:FlowType(required)
Aliases: Flow
# typeCastExpression
JavaScript
t.typeCastExpression(expression, typeAnnotation);
See also t.isTypeCastExpression(node, opts)and t.assertTypeCastExpression(node, opts).
AST Node TypeCastExpressionshape:
expression:Expression(required)typeAnnotation:TypeAnnotation(required)
Aliases: Flow , ExpressionWrapper , Expression
# typeParameter
JavaScript
t.typeParameter(bound, default, variance);
See also t.isTypeParameter(node, opts)and t.assertTypeParameter(node, opts).
AST Node TypeParametershape:
bound:TypeAnnotation(default:js)default:FlowType(default:js)variance:Variance(default:js)name:string(required)
Aliases: Flow
# typeParameterDeclaration
JavaScript
t.typeParameterDeclaration(params);
See also t.isTypeParameterDeclaration(node, opts)and t.assertTypeParameterDeclaration(node, opts).
AST Node TypeParameterDeclarationshape:
params:Array<TypeParameter>(required)
Aliases: Flow
# typeParameterInstantiation
JavaScript
t.typeParameterInstantiation(params);
See also t.isTypeParameterInstantiation(node, opts)and t.assertTypeParameterInstantiation(node, opts).
AST Node TypeParameterInstantiationshape:
params:Array<FlowType>(required)
Aliases: Flow
# typeofTypeAnnotation
JavaScript
t.typeofTypeAnnotation(argument);
See also t.isTypeofTypeAnnotation(node, opts)and t.assertTypeofTypeAnnotation(node, opts).
AST Node TypeofTypeAnnotationshape:
argument:FlowType(required)
Aliases: Flow , FlowType
# unaryExpression
JavaScript
t.unaryExpression(operator, argument, prefix);
See also t.isUnaryExpression(node, opts)and t.assertUnaryExpression(node, opts).
AST Node UnaryExpressionshape:
operator:"void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof"(required)argument:Expression(required)prefix:boolean(default:true)
Aliases: Standardized , UnaryLike , Expression
# unionTypeAnnotation
JavaScript
t.unionTypeAnnotation(types);
See also t.isUnionTypeAnnotation(node, opts)and t.assertUnionTypeAnnotation(node, opts).
AST Node UnionTypeAnnotationshape:
types:Array<FlowType>(required)
Aliases: Flow , FlowType
# updateExpression
JavaScript
t.updateExpression(operator, argument, prefix);
See also t.isUpdateExpression(node, opts)and t.assertUpdateExpression(node, opts).
AST Node UpdateExpressionshape:
operator:"++" | "--"(required)argument:Expression(required)prefix:boolean(default:false)
Aliases: Standardized , Expression
# v8IntrinsicIdentifier
JavaScript
t.v8IntrinsicIdentifier(name);
See also t.isV8IntrinsicIdentifier(node, opts)and t.assertV8IntrinsicIdentifier(node, opts).
AST Node V8IntrinsicIdentifiershape:
name:string(required)
Aliases: Miscellaneous
# variableDeclaration
JavaScript
t.variableDeclaration(kind, declarations);
History| | |
| :--- | :--- |
| | |
See also t.isVariableDeclaration(node, opts)and t.assertVariableDeclaration(node, opts).
AST Node VariableDeclarationshape:
kind:"var" | "let" | "const" | "using"(required)declarations:Array<VariableDeclarator>(required)declare:boolean(default:js, excluded from builder function)
Aliases: Standardized , Statement , Declaration
# variableDeclarator
JavaScript
t.variableDeclarator(id, init);
See also t.isVariableDeclarator(node, opts)and t.assertVariableDeclarator(node, opts).
AST Node VariableDeclaratorshape:
id:LVal(required)init:Expression(default:js)definite:boolean(default:js, excluded from builder function)
Aliases: Standardized
# variance
JavaScript
t.variance(kind);
See also t.isVariance(node, opts)and t.assertVariance(node, opts).
AST Node Varianceshape:
kind:"minus" | "plus"(required)
Aliases: Flow
# voidTypeAnnotation
JavaScript
t.voidTypeAnnotation();
See also t.isVoidTypeAnnotation(node, opts)and t.assertVoidTypeAnnotation(node, opts).
Aliases: Flow , FlowType , FlowBaseAnnotation
# whileStatement
JavaScript
t.whileStatement(test, body);
See also t.isWhileStatement(node, opts)and t.assertWhileStatement(node, opts).
AST Node WhileStatementshape:
test:Expression(required)body:Statement(required)
Aliases: Standardized , Statement , BlockParent , Loop , While , Scopable
# withStatement
JavaScript
t.withStatement(object, body);
See also t.isWithStatement(node, opts)and t.assertWithStatement(node, opts).
AST Node WithStatementshape:
object:Expression(required)body:Statement(required)
Aliases: Standardized , Statement
# yieldExpression
JavaScript
t.yieldExpression(argument, delegate);
See also t.isYieldExpression(node, opts)and t.assertYieldExpression(node, opts).
AST Node YieldExpressionshape:
argument:Expression(default:js)delegate:boolean(default:false)
Aliases: Standardized , Expression , Terminatorless
# Aliases
# Accessor
Deprecated. Will be removed in Babel 8.
JavaScript
t.isAccessor(node);
Covered nodes:
ClassAccessorProperty
# Binary
A cover of BinaryExpression and LogicalExpression, which share the same AST shape.
JavaScript
t.isBinary(node);
Covered nodes:
BinaryExpressionLogicalExpression
# Block
Deprecated. Will be removed in Babel 8.
JavaScript
t.isBlock(node);
Covered nodes:
BlockStatementProgramTSModuleBlock
# BlockParent
使用新LexicalEnvironment 启动执行上下文的 AST 节点的封面。换句话说,它们定义了范围let和const声明。
JavaScript
t.isBlockParent(node);
覆盖节点:
ArrowFunctionExpressionBlockStatementCatchClauseClassMethodClassPrivateMethodDoWhileStatementForInStatementForOfStatementForStatementFunctionDeclarationFunctionExpressionObjectMethodProgramStaticBlockSwitchStatementTSModuleBlockWhileStatement
# 班级
ClassExpression 和 ClassDeclaration 的封面,它们共享相同的 AST 形状。
JavaScript
t.isClass(node);
覆盖节点:
ClassDeclarationClassExpression
# 完成声明
表示完成记录的 语句。换句话说,它们定义了程序的控制流,例如循环何时中断或操作何时抛出严重错误。
JavaScript
t.isCompletionStatement(node);
覆盖节点:
BreakStatementContinueStatementReturnStatementThrowStatement
# 有条件的
ConditionalExpression 和 IfStatement 的封面,它们共享相同的 AST 形状。
JavaScript
t.isConditional(node);
覆盖节点:
ConditionalExpressionIfStatement
# 声明
任何声明 的封面。
JavaScript
t.isDeclaration(node);
覆盖节点:
ClassDeclarationDeclareClassDeclareExportAllDeclarationDeclareExportDeclarationDeclareFunctionDeclareInterfaceDeclareModuleDeclareModuleExportsDeclareOpaqueTypeDeclareTypeAliasDeclareVariableEnumDeclarationExportAllDeclarationExportDefaultDeclarationExportNamedDeclarationFunctionDeclarationImportDeclarationInterfaceDeclarationOpaqueTypeTSDeclareFunctionTSEnumDeclarationTSInterfaceDeclarationTSModuleDeclarationTSTypeAliasDeclarationTypeAliasVariableDeclaration
# 枚举体
Flow 枚举体的封面。
JavaScript
t.isEnumBody(node);
覆盖节点:
EnumBooleanBodyEnumNumberBodyEnumStringBodyEnumSymbolBody
# 枚举成员
Flow 枚举成员的封面。
JavaScript
t.isEnumMember(node);
覆盖节点:
EnumBooleanMemberEnumDefaultedMemberEnumNumberMemberEnumStringMember
# 出口报关
任何ExportDeclaration 的封面。
JavaScript
t.isExportDeclaration(node);
覆盖节点:
ExportAllDeclarationExportDefaultDeclarationExportNamedDeclaration
# 表达
任何Expression 的覆盖。
JavaScript
t.isExpression(node);
覆盖节点:
ArrayExpressionArrowFunctionExpressionAssignmentExpressionAwaitExpressionBigIntLiteralBinaryExpressionBindExpressionBooleanLiteralCallExpressionClassExpressionConditionalExpressionDecimalLiteralDoExpressionFunctionExpressionIdentifierImportJSXElementJSXFragmentLogicalExpressionMemberExpressionMetaPropertyModuleExpressionNewExpressionNullLiteralNumericLiteralObjectExpressionOptionalCallExpressionOptionalMemberExpressionParenthesizedExpressionPipelineBareFunctionPipelinePrimaryTopicReferencePipelineTopicExpressionRecordExpressionRegExpLiteralSequenceExpressionStringLiteralSuperTSAsExpressionTSInstantiationExpressionTSNonNullExpressionTSSatisfiesExpressionTSTypeAssertionTaggedTemplateExpressionTemplateLiteralThisExpressionTopicReferenceTupleExpressionTypeCastExpressionUnaryExpressionUpdateExpressionYieldExpression
# 表达式包装器
不具有运行时语义的表达式包装器。
JavaScript
t.isExpressionWrapper(node);
覆盖节点:
ExpressionStatementParenthesizedExpressionTypeCastExpression
# 流量
为 Flow 定义的 AST 节点的覆盖。
JavaScript
t.isFlow(node);
覆盖节点:
AnyTypeAnnotationArrayTypeAnnotationBooleanLiteralTypeAnnotationBooleanTypeAnnotationClassImplementsDeclareClassDeclareExportAllDeclarationDeclareExportDeclarationDeclareFunctionDeclareInterfaceDeclareModuleDeclareModuleExportsDeclareOpaqueTypeDeclareTypeAliasDeclareVariableDeclaredPredicateEmptyTypeAnnotationEnumBooleanBodyEnumBooleanMemberEnumDeclarationEnumDefaultedMemberEnumNumberBodyEnumNumberMemberEnumStringBodyEnumStringMemberEnumSymbolBodyExistsTypeAnnotationFunctionTypeAnnotationFunctionTypeParamGenericTypeAnnotationIndexedAccessTypeInferredPredicateInterfaceDeclarationInterfaceExtendsInterfaceTypeAnnotationIntersectionTypeAnnotationMixedTypeAnnotationNullLiteralTypeAnnotationNullableTypeAnnotationNumberLiteralTypeAnnotationNumberTypeAnnotationObjectTypeAnnotationObjectTypeCallPropertyObjectTypeIndexerObjectTypeInternalSlotObjectTypePropertyObjectTypeSpreadPropertyOpaqueTypeOptionalIndexedAccessTypeQualifiedTypeIdentifierStringLiteralTypeAnnotationStringTypeAnnotationSymbolTypeAnnotationThisTypeAnnotationTupleTypeAnnotationTypeAliasTypeAnnotationTypeCastExpressionTypeParameterTypeParameterDeclarationTypeParameterInstantiationTypeofTypeAnnotationUnionTypeAnnotationVarianceVoidTypeAnnotation
# FlowBaseAnnotation
主要流程类型注释的封面。
JavaScript
t.isFlowBaseAnnotation(node);
覆盖节点:
AnyTypeAnnotationBooleanTypeAnnotationEmptyTypeAnnotationMixedTypeAnnotationNullLiteralTypeAnnotationNumberTypeAnnotationStringTypeAnnotationSymbolTypeAnnotationThisTypeAnnotationVoidTypeAnnotation
# 流程声明
Flow 声明的封面。
JavaScript
t.isFlowDeclaration(node);
覆盖节点:
DeclareClassDeclareExportAllDeclarationDeclareExportDeclarationDeclareFunctionDeclareInterfaceDeclareModuleDeclareModuleExportsDeclareOpaqueTypeDeclareTypeAliasDeclareVariableInterfaceDeclarationOpaqueTypeTypeAlias
# FlowPredicate
Flow 谓词的覆盖。
JavaScript
t.isFlowPredicate(node);
覆盖节点:
DeclaredPredicateInferredPredicate
# 流程类型
Flow 类型注释的封面。
JavaScript
t.isFlowType(node);
覆盖节点:
AnyTypeAnnotationArrayTypeAnnotationBooleanLiteralTypeAnnotationBooleanTypeAnnotationEmptyTypeAnnotationExistsTypeAnnotationFunctionTypeAnnotationGenericTypeAnnotationIndexedAccessTypeInterfaceTypeAnnotationIntersectionTypeAnnotationMixedTypeAnnotationNullLiteralTypeAnnotationNullableTypeAnnotationNumberLiteralTypeAnnotationNumberTypeAnnotationObjectTypeAnnotationOptionalIndexedAccessTypeStringLiteralTypeAnnotationStringTypeAnnotationSymbolTypeAnnotationThisTypeAnnotationTupleTypeAnnotationTypeofTypeAnnotationUnionTypeAnnotationVoidTypeAnnotation
# 对于
ForStatement 和ForXStatement (opens new window) 的封面。
JavaScript
t.isFor(node);
覆盖节点:
ForInStatementForOfStatementForStatement
# ForXStatement
A cover of ForInStatements and ForOfStatements .
JavaScript
t.isForXStatement(node);
Covered nodes:
ForInStatementForOfStatement
# Function
A cover of functions and method s, the must have bodyand params. Note: Functionis different to FunctionParent. For example, a StaticBlockis a FunctionParentbut not Function.
JavaScript
t.isFunction(node);
Covered nodes:
ArrowFunctionExpressionClassMethodClassPrivateMethodFunctionDeclarationFunctionExpressionObjectMethod
# FunctionParent
A cover of AST nodes that start an execution context with new VariableEnvironment . In other words, they define the scope of vardeclarations. FunctionParent did not include Programsince Babel 7.
JavaScript
t.isFunctionParent(node);
Covered nodes:
ArrowFunctionExpressionClassMethodClassPrivateMethodFunctionDeclarationFunctionExpressionObjectMethodStaticBlockTSModuleBlock
# Immutable
A cover of immutable objects and JSX elements. An object is immutable if no other properties can be defined once created.
JavaScript
t.isImmutable(node);
Covered nodes:
BigIntLiteralBooleanLiteralDecimalLiteralJSXAttributeJSXClosingElementJSXClosingFragmentJSXElementJSXExpressionContainerJSXFragmentJSXOpeningElementJSXOpeningFragmentJSXSpreadChildJSXTextNullLiteralNumericLiteralStringLiteral
# ImportOrExportDeclaration
A cover of ImportDeclaration and ExportDeclaration
JavaScript
t.isImportOrExportDeclaration(node);
Covered nodes:
ExportAllDeclarationExportDefaultDeclarationExportNamedDeclarationImportDeclaration
# JSX
A cover of AST nodes defined for JSX .
JavaScript
t.isJSX(node);
Covered nodes:
JSXAttributeJSXClosingElementJSXClosingFragmentJSXElementJSXEmptyExpressionJSXExpressionContainerJSXFragmentJSXIdentifierJSXMemberExpressionJSXNamespacedNameJSXOpeningElementJSXOpeningFragmentJSXSpreadAttributeJSXSpreadChildJSXText
# LVal
A cover of left hand side expressions used in the leftof assignment expressions and ForXStatement s.
JavaScript
t.isLVal(node);
Covered nodes:
ArrayPatternAssignmentPatternIdentifierMemberExpressionObjectPatternRestElementTSAsExpressionTSNonNullExpressionTSParameterPropertyTSSatisfiesExpressionTSTypeAssertion
# Literal
A cover of Literal s, Regular Expression Literal s and Template Literal s.
JavaScript
t.isLiteral(node);
Covered nodes:
BigIntLiteralBooleanLiteralDecimalLiteralNullLiteralNumericLiteralRegExpLiteralStringLiteralTemplateLiteral
# Loop
A cover of loop statements.
JavaScript
t.isLoop(node);
Covered nodes:
DoWhileStatementForInStatementForOfStatementForStatementWhileStatement
# Method
A cover of object methods and class methods.
JavaScript
t.isMethod(node);
Covered nodes:
ClassMethodClassPrivateMethodObjectMethod
# Miscellaneous
A cover of non-standard AST types that are sometimes useful for development.
JavaScript
t.isMiscellaneous(node);
Covered nodes:
NoopPlaceholderV8IntrinsicIdentifier
# ModuleDeclaration
History| | | | :--- | :--- | | ``| |
警告
Deprecated, use ImportOrExportDeclaration instead. Check out PR #15266 for migration notes.
JavaScript
t.isModuleDeclaration(node);
Covered nodes:
ExportAllDeclarationExportDefaultDeclarationExportNamedDeclarationImportDeclaration
# ModuleSpecifier
A cover of import and export specifiers. Note: It is notthe ModuleSpecifier defined in the spec.
JavaScript
t.isModuleSpecifier(node);
Covered nodes:
ExportDefaultSpecifierExportNamespaceSpecifierExportSpecifierImportDefaultSpecifierImportNamespaceSpecifierImportSpecifier
# ObjectMember
A cover of members in an object literal.
JavaScript
t.isObjectMember(node);
Covered nodes:
ObjectMethodObjectProperty
# Pattern
A cover of BindingPattern except Identifiers.
JavaScript
t.isPattern(node);
Covered nodes:
ArrayPatternAssignmentPatternObjectPattern
# PatternLike
A cover of BindingPattern s.
JavaScript
t.isPatternLike(node);
Covered nodes:
ArrayPatternAssignmentPatternIdentifierObjectPatternRestElementTSAsExpressionTSNonNullExpressionTSSatisfiesExpressionTSTypeAssertion
# Private
A cover of private class elements and private identifiers.
JavaScript
t.isPrivate(node);
Covered nodes:
ClassPrivateMethodClassPrivatePropertyPrivateName
# Property
A cover of object properties and class properties.
JavaScript
t.isProperty(node);
Covered nodes:
ClassAccessorPropertyClassPrivatePropertyClassPropertyObjectProperty
# Pureish
A cover of AST nodes which do not have side-effects. In other words, there is no observable behaviour changes if they are evaluated more than once.
JavaScript
t.isPureish(node);
Covered nodes:
ArrowFunctionExpressionBigIntLiteralBooleanLiteralDecimalLiteralFunctionDeclarationFunctionExpressionNullLiteralNumericLiteralRegExpLiteralStringLiteral
# Scopable
A cover of FunctionParent and BlockParent .
JavaScript
t.isScopable(node);
Covered nodes:
ArrowFunctionExpressionBlockStatementCatchClauseClassDeclarationClassExpressionClassMethodClassPrivateMethodDoWhileStatementForInStatementForOfStatementForStatementFunctionDeclarationFunctionExpressionObjectMethodProgramStaticBlockSwitchStatementTSModuleBlockWhileStatement
# Standardized
A cover of AST nodes which are part of an official ECMAScript specification.
JavaScript
t.isStandardized(node);
Covered nodes:
ArrayExpressionArrayPatternArrowFunctionExpressionAssignmentExpressionAssignmentPatternAwaitExpressionBigIntLiteralBinaryExpressionBlockStatementBooleanLiteralBreakStatementCallExpressionCatchClauseClassAccessorPropertyClassBodyClassDeclarationClassExpressionClassMethodClassPrivateMethodClassPrivatePropertyClassPropertyConditionalExpressionContinueStatementDebuggerStatementDirectiveDirectiveLiteralDoWhileStatementEmptyStatementExportAllDeclarationExportDefaultDeclarationExportNamedDeclarationExportNamespaceSpecifierExportSpecifierExpressionStatementFileForInStatementForOfStatementForStatementFunctionDeclarationFunctionExpressionIdentifierIfStatementImportImportDeclarationImportDefaultSpecifierImportNamespaceSpecifierImportSpecifierInterpreterDirectiveLabeledStatementLogicalExpressionMemberExpressionMetaPropertyNewExpressionNullLiteralNumericLiteralObjectExpressionObjectMethodObjectPatternObjectPropertyOptionalCallExpressionOptionalMemberExpressionParenthesizedExpressionPrivateNameProgramRegExpLiteralRestElementReturnStatementSequenceExpressionSpreadElementStaticBlockStringLiteralSuperSwitchCaseSwitchStatementTaggedTemplateExpressionTemplateElementTemplateLiteralThisExpressionThrowStatementTryStatementUnaryExpressionUpdateExpressionVariableDeclarationVariableDeclaratorWhileStatementWithStatementYieldExpression
# Statement
A cover of any Statement s.
JavaScript
t.isStatement(node);
Covered nodes:
BlockStatementBreakStatementClassDeclarationContinueStatementDebuggerStatementDeclareClassDeclareExportAllDeclarationDeclareExportDeclarationDeclareFunctionDeclareInterfaceDeclareModuleDeclareModuleExportsDeclareOpaqueTypeDeclareTypeAliasDeclareVariableDoWhileStatementEmptyStatementEnumDeclarationExportAllDeclarationExportDefaultDeclarationExportNamedDeclarationExpressionStatementForInStatementForOfStatementForStatementFunctionDeclarationIfStatementImportDeclarationInterfaceDeclarationLabeledStatementOpaqueTypeReturnStatementSwitchStatementTSDeclareFunctionTSEnumDeclarationTSExportAssignmentTSImportEqualsDeclarationTSInterfaceDeclarationTSModuleDeclarationTSNamespaceExportDeclarationTSTypeAliasDeclarationThrowStatementTryStatementTypeAliasVariableDeclarationWhileStatementWithStatement
# TSBaseType
A cover of primary TypeScript type annotations.
JavaScript
t.isTSBaseType(node);
Covered nodes:
TSAnyKeywordTSBigIntKeywordTSBooleanKeywordTSIntrinsicKeywordTSLiteralTypeTSNeverKeywordTSNullKeywordTSNumberKeywordTSObjectKeywordTSStringKeywordTSSymbolKeywordTSThisTypeTSUndefinedKeywordTSUnknownKeywordTSVoidKeyword
# TSEntityName
A cover of ts entities.
JavaScript
t.isTSEntityName(node);
Covered nodes:
IdentifierTSQualifiedName
# TSType
A cover of TypeScript type annotations.
JavaScript
t.isTSType(node);
Covered nodes:
TSAnyKeywordTSArrayTypeTSBigIntKeywordTSBooleanKeywordTSConditionalTypeTSConstructorTypeTSExpressionWithTypeArgumentsTSFunctionTypeTSImportTypeTSIndexedAccessTypeTSInferTypeTSIntersectionTypeTSIntrinsicKeywordTSLiteralTypeTSMappedTypeTSNeverKeywordTSNullKeywordTSNumberKeywordTSObjectKeywordTSOptionalTypeTSParenthesizedTypeTSRestTypeTSStringKeywordTSSymbolKeywordTSThisTypeTSTupleTypeTSTypeLiteralTSTypeOperatorTSTypePredicateTSTypeQueryTSTypeReferenceTSUndefinedKeywordTSUnionTypeTSUnknownKeywordTSVoidKeyword
# TSTypeElement
A cover of TypeScript type declarations.
JavaScript
t.isTSTypeElement(node);
Covered nodes:
TSCallSignatureDeclarationTSConstructSignatureDeclarationTSIndexSignatureTSMethodSignatureTSPropertySignature
# Terminatorless
AST 节点的覆盖,当在操作符和操作数之间插入行终止符时,其语义将发生变化。
JavaScript
t.isTerminatorless(node);
覆盖节点:
AwaitExpressionBreakStatementContinueStatementReturnStatementThrowStatementYieldExpression
# 打字稿
为 TypeScript 定义的 AST 节点的封面。
JavaScript
t.isTypeScript(node);
覆盖节点:
TSAnyKeywordTSArrayTypeTSAsExpressionTSBigIntKeywordTSBooleanKeywordTSCallSignatureDeclarationTSConditionalTypeTSConstructSignatureDeclarationTSConstructorTypeTSDeclareFunctionTSDeclareMethodTSEnumDeclarationTSEnumMemberTSExportAssignmentTSExpressionWithTypeArgumentsTSExternalModuleReferenceTSFunctionTypeTSImportEqualsDeclarationTSImportTypeTSIndexSignatureTSIndexedAccessTypeTSInferTypeTSInstantiationExpressionTSInterfaceBodyTSInterfaceDeclarationTSIntersectionTypeTSIntrinsicKeywordTSLiteralTypeTSMappedTypeTSMethodSignatureTSModuleBlockTSModuleDeclarationTSNamedTupleMemberTSNamespaceExportDeclarationTSNeverKeywordTSNonNullExpressionTSNullKeywordTSNumberKeywordTSObjectKeywordTSOptionalTypeTSParameterPropertyTSParenthesizedTypeTSPropertySignatureTSQualifiedNameTSRestTypeTSSatisfiesExpressionTSStringKeywordTSSymbolKeywordTSThisTypeTSTupleTypeTSTypeAliasDeclarationTSTypeAnnotationTSTypeAssertionTSTypeLiteralTSTypeOperatorTSTypeParameterTSTypeParameterDeclarationTSTypeParameterInstantiationTSTypePredicateTSTypeQueryTSTypeReferenceTSUndefinedKeywordTSUnionTypeTSUnknownKeywordTSVoidKeyword
# 一元类
UnaryExpression 和 SpreadElement 的封面。
JavaScript
t.isUnaryLike(node);
覆盖节点:
SpreadElementUnaryExpression
# UserWhitespacable
已弃用。将在 Babel 8 中移除。
JavaScript
t.isUserWhitespacable(node);
覆盖节点:
ObjectMethodObjectPropertyObjectTypeCallPropertyObjectTypeIndexerObjectTypeInternalSlotObjectTypePropertyObjectTypeSpreadProperty
# 而
DoWhileStatement 和 WhileStatement 的封面,它们共享相同的 AST 形状。
JavaScript
t.isWhile(node);
覆盖节点:
DoWhileStatementWhileStatement