@babel/types
本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →
该模块包含用于手动构建 AST 节点以及检查 AST 节点类型的方法。
安装
- npm
- Yarn
- pnpm
- Bun
npm install --save-dev @babel/types
yarn add --dev @babel/types
pnpm add --save-dev @babel/types
bun add --dev @babel/types
API
节点构造器
anyTypeAnnotation
t.anyTypeAnnotation();
另请参阅 t.isAnyTypeAnnotation(node, opts) 和 t.assertAnyTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
argumentPlaceholder
t.argumentPlaceholder();
另请参阅 t.isArgumentPlaceholder(node, opts) 和 t.assertArgumentPlaceholder(node, opts)。
arrayExpression
t.arrayExpression(elements);
另请参阅 t.isArrayExpression(node, opts) 和 t.assertArrayExpression(node, opts)。
AST 节点 ArrayExpression 结构:
elements:(null | Expression | SpreadElement)[](默认值:[])
arrayPattern
t.arrayPattern(elements);
另请参阅 t.isArrayPattern(node, opts) 和 t.assertArrayPattern(node, opts)。
AST 节点 ArrayPattern 结构:
-
elements:(null | PatternLike)[](必需) -
decorators:Decorator[](默认值:null,不包含在构建器函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(default:null, 不包含在构建器函数中)
别名:Standardized、FunctionParameter、Pattern、PatternLike、LVal
arrayTypeAnnotation
t.arrayTypeAnnotation(elementType);
另请参阅 t.isArrayTypeAnnotation(node, opts) 和 t.assertArrayTypeAnnotation(node, opts)。
AST 节点 ArrayTypeAnnotation 结构:
elementType:FlowType(必需)
arrowFunctionExpression
t.arrowFunctionExpression(params, body, async);
另请参阅 t.isArrowFunctionExpression(node, opts) 和 t.assertArrowFunctionExpression(node, opts)。
AST 节点 ArrowFunctionExpression 结构:
-
params:FunctionParameter[](必需) -
body:BlockStatement | Expression(必需) -
async:boolean(默认值:false) -
expression:boolean(必需) -
generator:boolean(默认值:false,不包含在构建函数中) -
predicate:DeclaredPredicate | InferredPredicate(默认值:null, 不包含在构建器函数中) -
returnType:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,不包含在构建函数中) -
typeParameters:TypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认值:null,不包含在构建函数中)
别名: Standardized, Scopable, Function, BlockParent, FunctionParent, Expression, Pureish
assignmentExpression
t.assignmentExpression(operator, left, right);
另请参阅 t.isAssignmentExpression(node, opts) 和 t.assertAssignmentExpression(node, opts)。
AST 节点 AssignmentExpression 的结构:
-
operator:string(必需) -
left:LVal | OptionalMemberExpression(必需) -
right:Expression(必需)
assignmentPattern
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:Decorator[](默认值:null,不包含在构建器函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(default:null, 不包含在构建器函数中)
别名:Standardized、FunctionParameter、Pattern、PatternLike、LVal
awaitExpression
t.awaitExpression(argument);
另请参阅 t.isAwaitExpression(node, opts) 和 t.assertAwaitExpression(node, opts)。
AST 节点 AwaitExpression 的结构:
argument:Expression(必填)
别名: Standardized, Expression, Terminatorless
bigIntLiteral
t.bigIntLiteral(value);
另请参阅 t.isBigIntLiteral(node, opts) 和 t.assertBigIntLiteral(node, opts)。
AST 节点 BigIntLiteral 的结构:
value:string(required)
别名:Standardized, Expression, Pureish, Literal, Immutable
binaryExpression
t.binaryExpression(operator, left, right);
另请参阅 t.isBinaryExpression(node, opts) 和 t.assertBinaryExpression(node, opts)。
AST 节点 BinaryExpression 的结构:
-
operator:"+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>"(必需) -
left:Expression | PrivateName(必需) -
right:Expression(必需)
别名: Standardized, Binary, Expression
bindExpression
t.bindExpression(object, callee);
另请参阅 t.isBindExpression(node, opts) 和 t.assertBindExpression(node, opts)。
AST 节点 BindExpression 的结构:
-
object:Expression(必需) -
callee:Expression(必须)
别名:Expression
块语句
t.blockStatement(body, directives);
另请参阅 t.isBlockStatement(node, opts) 和 t.assertBlockStatement(node, opts)。
AST 节点 BlockStatement 的结构:
-
body:Statement[](必需) -
directives:Directive[](默认值:[])
别名:Standardized, Scopable, BlockParent, Block, Statement
布尔字面量
t.booleanLiteral(value);
另请参阅 t.isBooleanLiteral(node, opts) 和 t.assertBooleanLiteral(node, opts)。
AST 节点 BooleanLiteral 的结构:
value:boolean(必须)
别名:Standardized, Expression, Pureish, Literal, Immutable
布尔字面量类型注解
t.booleanLiteralTypeAnnotation(value);
另请参阅 t.isBooleanLiteralTypeAnnotation(node, opts) 和 t.assertBooleanLiteralTypeAnnotation(node, opts)。
AST 节点 BooleanLiteralTypeAnnotation 的结构:
value:boolean(必须)
布尔类型注解
t.booleanTypeAnnotation();
另请参阅 t.isBooleanTypeAnnotation(node, opts) 和 t.assertBooleanTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
break 语句
t.breakStatement(label);
另请参阅 t.isBreakStatement(node, opts) 和 t.assertBreakStatement(node, opts)。
AST 节点 BreakStatement 的结构:
label:Identifier(默认值:null)
别名:Standardized, Statement, Terminatorless, CompletionStatement
调用表达式
t.callExpression(callee, arguments);
另请参阅 t.isCallExpression(node, opts) 和 t.assertCallExpression(node, opts)。
AST 节点 CallExpression 的结构:
-
callee:Expression | Super | V8IntrinsicIdentifier(必需) -
arguments:(Expression | SpreadElement | ArgumentPlaceholder)[](必需) -
optional:boolean(默认值:null,不包含在构建器函数中) -
typeArguments:TypeParameterInstantiation(默认值:null,不包含在构建器函数中) -
typeParameters:TSTypeParameterInstantiation(默认值:null,不包含在构建器函数中)
catch 子句
t.catchClause(param, body);
另请参阅 t.isCatchClause(node, opts) 和 t.assertCatchClause(node, opts)。
AST 节点 CatchClause 的结构:
-
param:Identifier | ArrayPattern | ObjectPattern(默认值:null) -
body:BlockStatement(必需)
别名:Standardized, Scopable, BlockParent
classAccessorProperty
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(默认值:null) -
typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null) -
decorators:Decorator[](默认值:null) -
computed:boolean(默认值:false) -
static:boolean(默认值:false) -
abstract:boolean(默认值:null,不包含在构建函数中) -
accessibility:"public" | "private" | "protected"(默认值:null,不包含在构建器函数中) -
declare:boolean(默认:null, 构建函数中排除) -
definite:boolean(默认值:null,构建函数中不包含此参数) -
optional:boolean(默认值:null,不包含在构建器函数中) -
override:boolean(默认值:false,不包含在构建函数中) -
readonly:boolean(默认值:null,不包含在构建器函数中) -
variance:Variance(默认值:null,不包含在构建器函数中)
别名:Standardized, Property, Accessor
classBody
t.classBody(body);
另请参阅 t.isClassBody(node, opts) 和 t.assertClassBody(node, opts)。
AST 节点 ClassBody 的结构:
body:(ClassMethod | ClassPrivateMethod | ClassProperty | ClassPrivateProperty | ClassAccessorProperty | TSDeclareMethod | TSIndexSignature | StaticBlock)[](必需)
别名: Standardized
classDeclaration
t.classDeclaration(id, superClass, body, decorators);
另请参阅 t.isClassDeclaration(node, opts) 和 t.assertClassDeclaration(node, opts)。
AST 节点 ClassDeclaration 的结构:
-
id:Identifier(默认值:null) -
superClass:Expression(默认值:null) -
body:ClassBody(必填) -
decorators:Decorator[](默认值:null) -
abstract:boolean(默认值:null,不包含在构建函数中) -
declare:boolean(默认:null, 构建函数中排除) -
implements:(TSExpressionWithTypeArguments | ClassImplements)[](默认值:null,不包含在构建器函数中) -
mixins:InterfaceExtends(默认值:null,不包含在构建器函数中) -
superTypeParameters:TypeParameterInstantiation | TSTypeParameterInstantiation(默认值:null,不包含在构建器函数中) -
typeParameters:TypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认值:null,不包含在构建函数中)
别名:Standardized、Scopable、Class、Statement、Declaration
classExpression
t.classExpression(id, superClass, body, decorators);
另请参阅 t.isClassExpression(node, opts) 和 t.assertClassExpression(node, opts)。
AST 节点 ClassExpression 结构:
-
id:Identifier(默认值:null) -
superClass:Expression(默认值:null) -
body:ClassBody(必填) -
decorators:Decorator[](默认值:null) -
implements:(TSExpressionWithTypeArguments | ClassImplements)[](默认值:null,不包含在构建器函数中) -
mixins:InterfaceExtends(默认值:null,不包含在构建器函数中) -
superTypeParameters:TypeParameterInstantiation | TSTypeParameterInstantiation(默认值:null,不包含在构建器函数中) -
typeParameters:TypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认值:null,不包含在构建函数中)
别名:Standardized、Scopable、Class、Expression
classImplements
t.classImplements(id, typeParameters);
另请参阅 t.isClassImplements(node, opts) 和 t.assertClassImplements(node, opts)。
AST 节点 ClassImplements 结构:
-
id:Identifier(必需) -
typeParameters:TypeParameterInstantiation(默认:null)
别名: Flow
classMethod
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: 如果是计算属性则为Expression,否则为Identifier | Literal(必需) -
params:(FunctionParameter | TSParameterProperty)[](必需) -
body:BlockStatement(必需) -
computed:boolean(默认值:false) -
static:boolean(默认值:false) -
generator:boolean(默认值:false) -
async:boolean(默认值:false) -
abstract:boolean(默认值:null,不包含在构建函数中) -
access:"public" | "private" | "protected"(默认值:null,不包含在构建函数中) -
accessibility:"public" | "private" | "protected"(默认值:null,不包含在构建器函数中) -
decorators:Decorator[](默认值:null,不包含在构建器函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
override:boolean(默认值:false,不包含在构建函数中) -
returnType:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,不包含在构建函数中) -
typeParameters:TypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认值:null,不包含在构建函数中)
别名:Standardized, Function, Scopable, BlockParent, FunctionParent, Method
classPrivateMethod
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:(FunctionParameter | TSParameterProperty)[](必需) -
body:BlockStatement(必需) -
static:boolean(默认值:false) -
abstract:boolean(默认值:null,不包含在构建函数中) -
access:"public" | "private" | "protected"(默认值:null,不包含在构建函数中) -
accessibility:"public" | "private" | "protected"(默认值:null,不包含在构建器函数中) -
async:boolean(默认值:false,不包含在构建函数中) -
computed: 'false'(默认值:false,不包含在构建函数中) -
decorators:Decorator[](默认值:null,不包含在构建器函数中) -
generator:boolean(默认值:false,不包含在构建函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
override:boolean(默认值:false,不包含在构建函数中) -
returnType:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,不包含在构建函数中) -
typeParameters:TypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认值:null,不包含在构建函数中)
别名:Standardized, Function, Scopable, BlockParent, FunctionParent, Method, Private
classPrivateProperty
t.classPrivateProperty(key, value, decorators, static);
另见 t.isClassPrivateProperty(node, opts) 和 t.assertClassPrivateProperty(node, opts)。
AST 节点 ClassPrivateProperty 结构:
-
key:PrivateName(必需) -
value:Expression(默认值:null) -
decorators:Decorator[](默认值:null) -
static:boolean(默认值:false) -
definite:boolean(默认值:null,构建函数中不包含此参数) -
optional:boolean(默认值:null,不包含在构建器函数中) -
readonly:boolean(默认值:null,不包含在构建器函数中) -
typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(default:null, 不包含在构建器函数中) -
variance:Variance(默认值:null,不包含在构建器函数中)
别名:Standardized, Property, Private
classProperty
t.classProperty(key, value, typeAnnotation, decorators, computed, static);
History
| Version | Changes |
|---|---|
v7.6.0 | Supports static |
另请参阅 t.isClassProperty(node, opts) 和 t.assertClassProperty(node, opts)。
AST 节点 ClassProperty 的形状:
-
key:Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression(必需) -
value:Expression(默认值:null) -
typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null) -
decorators:Decorator[](默认值:null) -
computed:boolean(默认值:false) -
static:boolean(默认值:false) -
abstract:boolean(默认值:null,不包含在构建函数中) -
accessibility:"public" | "private" | "protected"(默认值:null,不包含在构建器函数中) -
declare:boolean(默认:null, 构建函数中排除) -
definite:boolean(默认值:null,构建函数中不包含此参数) -
optional:boolean(默认值:null,不包含在构建器函数中) -
override:boolean(默认值:false,不包含在构建函数中) -
readonly:boolean(默认值:null,不包含在构建器函数中) -
variance:Variance(默认值:null,不包含在构建器函数中)
别名:Standardized, Property
conditionalExpression
t.conditionalExpression(test, consequent, alternate);
另请参阅 t.isConditionalExpression(node, opts) 和 t.assertConditionalExpression(node, opts)。
AST 节点 ConditionalExpression 的形状:
-
test:Expression(必需) -
consequent:Expression(必需) -
alternate:Expression(必需)
别名:Standardized, Expression, Conditional
continueStatement
t.continueStatement(label);
另请参阅 t.isContinueStatement(node, opts) 和 t.assertContinueStatement(node, opts)。
AST 节点 ContinueStatement 的形状:
label:Identifier(默认值:null)
别名:Standardized, Statement, Terminatorless, CompletionStatement
debuggerStatement
t.debuggerStatement();
另请参阅 t.isDebuggerStatement(node, opts) 和 t.assertDebuggerStatement(node, opts)。
别名: Standardized, Statement
decimalLiteral
t.decimalLiteral(value);
另请参见 t.isDecimalLiteral(node, opts) 和 t.assertDecimalLiteral(node, opts)。
AST 节点 DecimalLiteral 的结构:
value:string(required)
别名: Expression, Pureish, Literal, Immutable
declareClass
t.declareClass(id, typeParameters, extends, body);
另请参见 t.isDeclareClass(node, opts) 和 t.assertDeclareClass(node, opts)。
AST 节点 DeclareClass 的结构:
-
id:Identifier(必需) -
typeParameters:TypeParameterDeclaration(默认值:null) -
extends:InterfaceExtends[](默认值:null) -
body:ObjectTypeAnnotation(必需) -
implements:ClassImplements[](默认值:null,不包含在构建器函数中) -
mixins:InterfaceExtends[](默认值:null,不包含在构建器函数中)
别名:Flow, FlowDeclaration, Statement, Declaration
declareExportAllDeclaration
t.declareExportAllDeclaration(source, attributes);
另请参见 t.isDeclareExportAllDeclaration(node, opts) 和 t.assertDeclareExportAllDeclaration(node, opts)。
AST 节点 DeclareExportAllDeclaration 的结构:
-
source:StringLiteral(必需) -
attributes:ImportAttribute[](默认值:null) -
assertions:ImportAttribute[](默认值:null,不包含在构建器函数中) -
exportKind:"type" | "value"(默认值:null,不包含在构建器函数中)
别名:Flow, FlowDeclaration, Statement, Declaration
declareExportDeclaration
t.declareExportDeclaration(declaration, specifiers, source, attributes);
另请参见 t.isDeclareExportDeclaration(node, opts) 和 t.assertDeclareExportDeclaration(node, opts)。
AST 节点 DeclareExportDeclaration 的结构:
-
declaration:Flow(默认值:null) -
specifiers:(ExportSpecifier | ExportNamespaceSpecifier)[](默认值:null) -
source:StringLiteral(默认值:null) -
attributes:ImportAttribute[](默认值:null) -
assertions:ImportAttribute[](默认值:null,不包含在构建器函数中) -
default:boolean(默认值:null,不包含在构建函数中)
别名:Flow, FlowDeclaration, Statement, Declaration
declareFunction
t.declareFunction(id);
另请参见 t.isDeclareFunction(node, opts) 和 t.assertDeclareFunction(node, opts)。
AST 节点 DeclareFunction 的结构:
-
id:Identifier(必需) -
predicate:DeclaredPredicate(默认值:null,不包含在构建函数中)
别名:Flow, FlowDeclaration, Statement, Declaration
declareInterface
t.declareInterface(id, typeParameters, extends, body);
另见 t.isDeclareInterface(node, opts) 和 t.assertDeclareInterface(node, opts)。
AST 节点 DeclareInterface 的结构:
-
id:Identifier(必需) -
typeParameters:TypeParameterDeclaration(默认值:null) -
extends:InterfaceExtends[](默认值:null) -
body:ObjectTypeAnnotation(必需)
别名:Flow, FlowDeclaration, Statement, Declaration
declareModule
t.declareModule(id, body, kind);
另见 t.isDeclareModule(node, opts) 和 t.assertDeclareModule(node, opts)。
AST 节点 DeclareModule 的结构:
-
id:Identifier | StringLiteral(必填) -
body:BlockStatement(必需) -
kind:"CommonJS" | "ES"(默认值:null)
别名:Flow, FlowDeclaration, Statement, Declaration
declareModuleExports
t.declareModuleExports(typeAnnotation);
另见 t.isDeclareModuleExports(node, opts) 和 t.assertDeclareModuleExports(node, opts)。
AST 节点 DeclareModuleExports 的结构:
typeAnnotation:TypeAnnotation(必需)
别名:Flow, FlowDeclaration, Statement, Declaration
declareOpaqueType
t.declareOpaqueType(id, typeParameters, supertype);
另见 t.isDeclareOpaqueType(node, opts) 和 t.assertDeclareOpaqueType(node, opts)。
AST 节点 DeclareOpaqueType 的结构:
-
id:Identifier(必需) -
typeParameters:TypeParameterDeclaration(默认值:null) -
supertype:FlowType(默认:null) -
impltype:FlowType(默认值:null, 不包含在构建器函数中)
别名:Flow, FlowDeclaration, Statement, Declaration
declareTypeAlias
t.declareTypeAlias(id, typeParameters, right);
另见 t.isDeclareTypeAlias(node, opts) 和 t.assertDeclareTypeAlias(node, opts)。
AST 节点 DeclareTypeAlias 的结构:
-
id:Identifier(必需) -
typeParameters:TypeParameterDeclaration(默认值:null) -
right:FlowType(必需)
别名:Flow, FlowDeclaration, Statement, Declaration
declareVariable
t.declareVariable(id);
另见 t.isDeclareVariable(node, opts) 和 t.assertDeclareVariable(node, opts)。
AST 节点 DeclareVariable 的结构:
id:Identifier(必需)
别名:Flow, FlowDeclaration, Statement, Declaration
declaredPredicate
t.declaredPredicate(value);
另请参阅 t.isDeclaredPredicate(node, opts) 和 t.assertDeclaredPredicate(node, opts)。
AST 节点 DeclaredPredicate 结构:
value:Flow(必填)
别名: Flow, FlowPredicate
decorator
t.decorator(expression);
另请参阅 t.isDecorator(node, opts) 和 t.assertDecorator(node, opts)。
AST 节点 Decorator 结构:
expression:Expression(必需)
directive
t.directive(value);
另请参阅 t.isDirective(node, opts) 和 t.assertDirective(node, opts)。
AST 节点 Directive 结构:
value:DirectiveLiteral(必填)
别名: Standardized
directiveLiteral
t.directiveLiteral(value);
另请参阅 t.isDirectiveLiteral(node, opts) 和 t.assertDirectiveLiteral(node, opts)。
AST 节点 DirectiveLiteral 结构:
value:string(required)
别名: Standardized
doExpression
t.doExpression(body, async);
另请参阅 t.isDoExpression(node, opts) 和 t.assertDoExpression(node, opts)。
AST 节点 DoExpression 结构:
-
body:BlockStatement(必需) -
async:boolean(默认值:false)
别名:Expression
doWhileStatement
t.doWhileStatement(test, body);
另请参阅 t.isDoWhileStatement(node, opts) 和 t.assertDoWhileStatement(node, opts)。
AST 节点 DoWhileStatement 结构:
-
test:Expression(必需) -
body:Statement(必需)
别名: Standardized, Statement, BlockParent, Loop, While, Scopable
emptyStatement
t.emptyStatement();
另请参阅 t.isEmptyStatement(node, opts) 和 t.assertEmptyStatement(node, opts)。
别名: Standardized, Statement
emptyTypeAnnotation
t.emptyTypeAnnotation();
另请参阅 t.isEmptyTypeAnnotation(node, opts) 和 t.assertEmptyTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
enumBooleanBody
t.enumBooleanBody(members);
另请参阅 t.isEnumBooleanBody(node, opts) 和 t.assertEnumBooleanBody(node, opts)。
AST 节点 EnumBooleanBody 结构:
-
members:EnumBooleanMember[](必需) -
explicitType:boolean(必需) -
hasUnknownMembers:boolean(必需)
布尔枚举成员
t.enumBooleanMember(id);
另见 t.isEnumBooleanMember(node, opts) 和 t.assertEnumBooleanMember(node, opts)。
AST 节点 EnumBooleanMember 的结构:
-
id:Identifier(必需) -
init:BooleanLiteral(必需)
别名:Flow, EnumMember
枚举声明
t.enumDeclaration(id, body);
另见 t.isEnumDeclaration(node, opts) 和 t.assertEnumDeclaration(node, opts)。
AST 节点 EnumDeclaration 的结构:
-
id:Identifier(必需) -
body:EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody(必需)
别名:Flow, Statement, Declaration
默认枚举成员
t.enumDefaultedMember(id);
另见 t.isEnumDefaultedMember(node, opts) 和 t.assertEnumDefaultedMember(node, opts)。
AST 节点 EnumDefaultedMember 的结构:
id:Identifier(必需)
别名:Flow, EnumMember
数值枚举体
t.enumNumberBody(members);
另见 t.isEnumNumberBody(node, opts) 和 t.assertEnumNumberBody(node, opts)。
AST 节点 EnumNumberBody 的结构:
-
members:EnumNumberMember[](必需) -
explicitType:boolean(必需) -
hasUnknownMembers:boolean(必需)
数值枚举成员
t.enumNumberMember(id, init);
另见 t.isEnumNumberMember(node, opts) 和 t.assertEnumNumberMember(node, opts)。
AST 节点 EnumNumberMember 的结构:
-
id:Identifier(必需) -
init:NumericLiteral(必需)
别名:Flow, EnumMember
字符串枚举体
t.enumStringBody(members);
另见 t.isEnumStringBody(node, opts) 和 t.assertEnumStringBody(node, opts)。
AST 节点 EnumStringBody 的结构:
-
members:(EnumStringMember | EnumDefaultedMember)[](必需) -
explicitType:boolean(必需) -
hasUnknownMembers:boolean(必需)
字符串枚举成员
t.enumStringMember(id, init);
另见 t.isEnumStringMember(node, opts) 和 t.assertEnumStringMember(node, opts)。
AST 节点 EnumStringMember 的结构:
-
id:Identifier(必需) -
init:StringLiteral(必需)
别名:Flow, EnumMember
enumSymbolBody
t.enumSymbolBody(members);
另请参阅 t.isEnumSymbolBody(node, opts) 和 t.assertEnumSymbolBody(node, opts)。
AST 节点 EnumSymbolBody 的结构:
-
members:EnumDefaultedMember[](必需) -
hasUnknownMembers:boolean(必需)
existsTypeAnnotation
t.existsTypeAnnotation();
另请参阅 t.isExistsTypeAnnotation(node, opts) 和 t.assertExistsTypeAnnotation(node, opts)。
exportAllDeclaration
t.exportAllDeclaration(source, attributes);
History
| Version | Changes |
|---|---|
v7.29.0 | Supports attributes |
另请参阅 t.isExportAllDeclaration(node, opts) 和 t.assertExportAllDeclaration(node, opts)。
AST 节点 ExportAllDeclaration 的结构:
-
source:StringLiteral(必需) -
attributes:ImportAttribute[](默认值:null) -
assertions:ImportAttribute[](默认值:null,不包含在构建器函数中) -
exportKind:"type" | "value"(默认值:null,不包含在构建器函数中)
别名:Standardized、Statement、Declaration、ImportOrExportDeclaration、ExportDeclaration
exportDefaultDeclaration
t.exportDefaultDeclaration(declaration);
另请参阅 t.isExportDefaultDeclaration(node, opts) 和 t.assertExportDefaultDeclaration(node, opts)。
AST 节点 ExportDefaultDeclaration 的结构:
-
declaration:TSDeclareFunction | FunctionDeclaration | ClassDeclaration | Expression(必需) -
exportKind:"value"(默认值:null,不包含在构建函数中)
别名:Standardized、Statement、Declaration、ImportOrExportDeclaration、ExportDeclaration
exportDefaultSpecifier
t.exportDefaultSpecifier(exported);
另请参阅 t.isExportDefaultSpecifier(node, opts) 和 t.assertExportDefaultSpecifier(node, opts)。
AST 节点 ExportDefaultSpecifier 的结构:
exported:Identifier(必填)
exportNamedDeclaration
t.exportNamedDeclaration(declaration, specifiers, source, attributes);
History
| Version | Changes |
|---|---|
v7.29.0 | Supports attributes |
另请参阅 t.isExportNamedDeclaration(node, opts) 和 t.assertExportNamedDeclaration(node, opts)。
AST 节点 ExportNamedDeclaration 的结构:
-
declaration:Declaration(默认值:null) -
specifiers:(ExportSpecifier | ExportDefaultSpecifier | ExportNamespaceSpecifier)[](默认值:[]) -
source:StringLiteral(默认值:null) -
attributes:ImportAttribute[](默认值:null) -
assertions:ImportAttribute[](默认值:null,不包含在构建器函数中) -
exportKind:"type" | "value"(默认值:null,不包含在构建器函数中)
别名:Standardized、Statement、Declaration、ImportOrExportDeclaration、ExportDeclaration
exportNamespaceSpecifier
t.exportNamespaceSpecifier(exported);
另见 t.isExportNamespaceSpecifier(node, opts) 和 t.assertExportNamespaceSpecifier(node, opts)。
AST 节点 ExportNamespaceSpecifier 的结构:
exported:Identifier(必填)
别名:Standardized, ModuleSpecifier
exportSpecifier
t.exportSpecifier(local, exported);
另见 t.isExportSpecifier(node, opts) 和 t.assertExportSpecifier(node, opts)。
AST 节点 ExportSpecifier 的结构:
-
local:Identifier(必需) -
exported:Identifier | StringLiteral(必填) -
exportKind:"type" | "value"(默认值:null,不包含在构建器函数中)
别名:Standardized, ModuleSpecifier
expressionStatement
t.expressionStatement(expression);
另见 t.isExpressionStatement(node, opts) 和 t.assertExpressionStatement(node, opts)。
AST 节点 ExpressionStatement 的结构:
expression:Expression(必需)
别名:Standardized、Statement、ExpressionWrapper
file
t.file(program, comments, tokens);
另见 t.isFile(node, opts) 和 t.assertFile(node, opts)。
AST 节点 File 的结构:
-
program:Program(必填) -
comments:(CommentBlock | CommentLine)[](默认值:null) -
tokens:any[](默认值:null)
别名: Standardized
forInStatement
t.forInStatement(left, right, body);
另见 t.isForInStatement(node, opts) 和 t.assertForInStatement(node, opts)。
AST 节点 ForInStatement 的结构:
-
left:VariableDeclaration | LVal(必填) -
right:Expression(必需) -
body:Statement(必需)
别名: Standardized, Scopable, Statement, For, BlockParent, Loop, ForXStatement
forOfStatement
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, Scopable, Statement, For, BlockParent, Loop, ForXStatement
forStatement
t.forStatement(init, test, update, body);
另请参阅 t.isForStatement(node, opts) 和 t.assertForStatement(node, opts)。
AST 节点 ForStatement 结构:
-
init:VariableDeclaration | Expression(默认值:null) -
test:Expression(默认值:null) -
update:Expression(默认值:null) -
body:Statement(必需)
别名: Standardized, Scopable, Statement, For, BlockParent, Loop
functionDeclaration
t.functionDeclaration(id, params, body, generator, async);
另请参阅 t.isFunctionDeclaration(node, opts) 和 t.assertFunctionDeclaration(node, opts)。
AST 节点 FunctionDeclaration 结构:
-
id:Identifier(默认值:null) -
params:FunctionParameter[](必需) -
body:BlockStatement(必需) -
generator:boolean(默认值:false) -
async:boolean(默认值:false) -
declare:boolean(默认:null, 构建函数中排除) -
predicate:DeclaredPredicate | InferredPredicate(默认值:null, 不包含在构建器函数中) -
returnType:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,不包含在构建函数中) -
typeParameters:TypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认值:null,不包含在构建函数中)
别名: Standardized, Scopable, Function, BlockParent, FunctionParent, Statement, Pureish, Declaration
functionExpression
t.functionExpression(id, params, body, generator, async);
另请参阅 t.isFunctionExpression(node, opts) 和 t.assertFunctionExpression(node, opts)。
AST 节点 FunctionExpression 结构:
-
id:Identifier(默认值:null) -
params:FunctionParameter[](必需) -
body:BlockStatement(必需) -
generator:boolean(默认值:false) -
async:boolean(默认值:false) -
predicate:DeclaredPredicate | InferredPredicate(默认值:null, 不包含在构建器函数中) -
returnType:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,不包含在构建函数中) -
typeParameters:TypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认值:null,不包含在构建函数中)
别名: Standardized, Scopable, Function, BlockParent, FunctionParent, Expression, Pureish
functionTypeAnnotation
t.functionTypeAnnotation(typeParameters, params, rest, returnType);
另请参阅 t.isFunctionTypeAnnotation(node, opts) 和 t.assertFunctionTypeAnnotation(node, opts)。
AST 节点 FunctionTypeAnnotation 的结构:
-
typeParameters:TypeParameterDeclaration(默认值:null) -
params:FunctionTypeParam[](必需) -
rest:FunctionTypeParam(默认值:null) -
returnType:FlowType(必填) -
this:FunctionTypeParam(默认值:null,构建函数中排除)
functionTypeParam
t.functionTypeParam(name, typeAnnotation);
另请参阅 t.isFunctionTypeParam(node, opts) 和 t.assertFunctionTypeParam(node, opts)。
AST 节点 FunctionTypeParam 的结构:
-
name:Identifier(默认值:null) -
typeAnnotation:FlowType(必需) -
optional:boolean(默认值:null,不包含在构建器函数中)
别名: Flow
genericTypeAnnotation
t.genericTypeAnnotation(id, typeParameters);
另请参阅 t.isGenericTypeAnnotation(node, opts) 和 t.assertGenericTypeAnnotation(node, opts)。
AST 节点 GenericTypeAnnotation 的结构:
-
id:Identifier | QualifiedTypeIdentifier(必需) -
typeParameters:TypeParameterInstantiation(默认:null)
identifier
t.identifier(name);
另请参阅 t.isIdentifier(node, opts) 和 t.assertIdentifier(node, opts)。
AST 节点 Identifier 的结构:
-
name:string(必填) -
decorators:Decorator[](默认值:null,不包含在构建器函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(default:null, 不包含在构建器函数中)
别名:Standardized, Expression, FunctionParameter, PatternLike, LVal, TSEntityName
ifStatement
t.ifStatement(test, consequent, alternate);
另请参阅 t.isIfStatement(node, opts) 和 t.assertIfStatement(node, opts)。
AST 节点 IfStatement 的结构:
-
test:Expression(必需) -
consequent:Statement(必填) -
alternate:Statement(默认值:null)
别名:Standardized, Statement, Conditional
import
t.import();
另请参阅 t.isImport(node, opts) 和 t.assertImport(node, opts)。
importAttribute
t.importAttribute(key, value);
另请参见 t.isImportAttribute(node, opts) 和 t.assertImportAttribute(node, opts)。
AST 节点 ImportAttribute 结构:
-
key:Identifier | StringLiteral(必需) -
value:StringLiteral(必需)
别名: Standardized
importDeclaration
t.importDeclaration(specifiers, source, attributes);
History
| Version | Changes |
|---|---|
v7.20.0 | Supports module |
v7.29.0 | Supports attributes |
另请参见 t.isImportDeclaration(node, opts) 和 t.assertImportDeclaration(node, opts)。
AST 节点 ImportDeclaration 结构:
-
specifiers:(ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[](必需) -
source:StringLiteral(必需) -
attributes:ImportAttribute[](默认值:null) -
assertions:ImportAttribute[](默认值:null,不包含在构建器函数中) -
importKind:"type" | "typeof" | "value"(默认值:null,构建器函数中不包含) -
module:boolean(默认值:null,构建器函数中不包含) -
phase:"source" | "defer"(默认值:null,构建器函数中不包含)
别名:Standardized, Statement, Declaration, ImportOrExportDeclaration
importDefaultSpecifier
t.importDefaultSpecifier(local);
另请参见 t.isImportDefaultSpecifier(node, opts) 和 t.assertImportDefaultSpecifier(node, opts)。
AST 节点 ImportDefaultSpecifier 结构:
local:Identifier(必需)
别名:Standardized, ModuleSpecifier
importExpression
t.importExpression(source, options);
另请参见 t.isImportExpression(node, opts) 和 t.assertImportExpression(node, opts)。
AST 节点 ImportExpression 结构:
-
source:Expression(必需) -
options:Expression(默认值:null) -
phase:"source" | "defer"(默认值:null,构建器函数中不包含)
importNamespaceSpecifier
t.importNamespaceSpecifier(local);
另请参见 t.isImportNamespaceSpecifier(node, opts) 和 t.assertImportNamespaceSpecifier(node, opts)。
AST 节点 ImportNamespaceSpecifier 结构:
local:Identifier(必需)
别名:Standardized, ModuleSpecifier
importSpecifier
t.importSpecifier(local, imported);
另请参见 t.isImportSpecifier(node, opts) 和 t.assertImportSpecifier(node, opts)。
AST 节点 ImportSpecifier 结构:
-
local:Identifier(必需) -
imported:Identifier | StringLiteral(必需) -
importKind:"type" | "typeof" | "value"(默认值:null,构建器函数中不包含)
别名:Standardized, ModuleSpecifier
indexedAccessType
t.indexedAccessType(objectType, indexType);
另请参见 t.isIndexedAccessType(node, opts) 和 t.assertIndexedAccessType(node, opts)。
AST 节点 IndexedAccessType 结构:
-
objectType:FlowType(必须) -
indexType:FlowType(必须)
inferredPredicate
t.inferredPredicate();
另请参见 t.isInferredPredicate(node, opts) 和 t.assertInferredPredicate(node, opts)。
别名: Flow, FlowPredicate
interfaceDeclaration
t.interfaceDeclaration(id, typeParameters, extends, body);
另请参见 t.isInterfaceDeclaration(node, opts) 和 t.assertInterfaceDeclaration(node, opts)。
AST 节点 InterfaceDeclaration 结构:
-
id:Identifier(必需) -
typeParameters:TypeParameterDeclaration(默认值:null) -
extends:InterfaceExtends[](默认值:null) -
body:ObjectTypeAnnotation(必需)
别名:Flow, FlowDeclaration, Statement, Declaration
interfaceExtends
t.interfaceExtends(id, typeParameters);
另请参见 t.isInterfaceExtends(node, opts) 和 t.assertInterfaceExtends(node, opts)。
AST 节点 InterfaceExtends 结构:
-
id:Identifier | QualifiedTypeIdentifier(必需) -
typeParameters:TypeParameterInstantiation(默认:null)
别名: Flow
interfaceTypeAnnotation
t.interfaceTypeAnnotation(extends, body);
另请参见 t.isInterfaceTypeAnnotation(node, opts) 和 t.assertInterfaceTypeAnnotation(node, opts)。
AST 节点 InterfaceTypeAnnotation 结构:
-
extends:InterfaceExtends[](默认值:null) -
body:ObjectTypeAnnotation(必需)
interpreterDirective
t.interpreterDirective(value);
另请参见 t.isInterpreterDirective(node, opts) 和 t.assertInterpreterDirective(node, opts)。
AST 节点 InterpreterDirective 结构:
value:string(required)
别名: Standardized
intersectionTypeAnnotation
t.intersectionTypeAnnotation(types);
另请参见 t.isIntersectionTypeAnnotation(node, opts) 和 t.assertIntersectionTypeAnnotation(node, opts)。
AST 节点 IntersectionTypeAnnotation 结构:
types:FlowType[](必需)
jsxAttribute
t.jsxAttribute(name, value);
另请参见 t.isJSXAttribute(node, opts) 和 t.assertJSXAttribute(node, opts)。
AST 节点 JSXAttribute 结构:
-
name:JSXIdentifier | JSXNamespacedName(必需) -
value:JSXElement | JSXFragment | StringLiteral | JSXExpressionContainer(默认值:null)
jsxClosingElement
t.jsxClosingElement(name);
另请参阅 t.isJSXClosingElement(node, opts) 和 t.assertJSXClosingElement(node, opts)。
AST 节点 JSXClosingElement 结构:
name:JSXIdentifier | JSXMemberExpression | JSXNamespacedName(必须)
jsxClosingFragment
t.jsxClosingFragment();
另请参阅 t.isJSXClosingFragment(node, opts) 和 t.assertJSXClosingFragment(node, opts)。
jsxElement
t.jsxElement(openingElement, closingElement, children, selfClosing);
另请参阅 t.isJSXElement(node, opts) 和 t.assertJSXElement(node, opts)。
AST 节点 JSXElement 结构:
-
openingElement:JSXOpeningElement(必需) -
closingElement:JSXClosingElement(默认值:null) -
children:(JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment)[](必需) -
selfClosing:boolean(默认值:null)
别名: JSX, Immutable, Expression
jsxEmptyExpression
t.jsxEmptyExpression();
另请参阅 t.isJSXEmptyExpression(node, opts) 和 t.assertJSXEmptyExpression(node, opts)。
别名: JSX
jsxExpressionContainer
t.jsxExpressionContainer(expression);
另请参阅 t.isJSXExpressionContainer(node, opts) 和 t.assertJSXExpressionContainer(node, opts)。
AST 节点 JSXExpressionContainer 结构:
expression:Expression | JSXEmptyExpression(必需)
jsxFragment
t.jsxFragment(openingFragment, closingFragment, children);
另请参阅 t.isJSXFragment(node, opts) 和 t.assertJSXFragment(node, opts)。
AST 节点 JSXFragment 结构:
-
openingFragment:JSXOpeningFragment(必需) -
closingFragment:JSXClosingFragment(必需) -
children:(JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment)[](必需)
别名: JSX, Immutable, Expression
jsxIdentifier
t.jsxIdentifier(name);
另请参阅 t.isJSXIdentifier(node, opts) 和 t.assertJSXIdentifier(node, opts)。
AST 节点 JSXIdentifier 结构:
name:string(必填)
别名: JSX
jsxMemberExpression
t.jsxMemberExpression(object, property);
另请参阅 t.isJSXMemberExpression(node, opts) 和 t.assertJSXMemberExpression(node, opts)。
AST 节点 JSXMemberExpression 的结构:
-
object:JSXMemberExpression | JSXIdentifier(必须) -
property:JSXIdentifier(必须)
别名: JSX
jsxNamespacedName
t.jsxNamespacedName(namespace, name);
另请参阅 t.isJSXNamespacedName(node, opts) 和 t.assertJSXNamespacedName(node, opts)。
AST 节点 JSXNamespacedName 的结构:
-
namespace:JSXIdentifier(必须) -
name:JSXIdentifier(必须)
别名: JSX
jsxOpeningElement
t.jsxOpeningElement(name, attributes, selfClosing);
另请参阅 t.isJSXOpeningElement(node, opts) 和 t.assertJSXOpeningElement(node, opts)。
AST 节点 JSXOpeningElement 的结构:
-
name:JSXIdentifier | JSXMemberExpression | JSXNamespacedName(必须) -
attributes:(JSXAttribute | JSXSpreadAttribute)[](必需) -
selfClosing:boolean(默认值:false) -
typeArguments:TypeParameterInstantiation(默认值:null,不包含在构建器函数中) -
typeParameters:TSTypeParameterInstantiation(默认值:null,不包含在构建器函数中)
jsxOpeningFragment
t.jsxOpeningFragment();
另请参阅 t.isJSXOpeningFragment(node, opts) 和 t.assertJSXOpeningFragment(node, opts)。
jsxSpreadAttribute
t.jsxSpreadAttribute(argument);
另请参阅 t.isJSXSpreadAttribute(node, opts) 和 t.assertJSXSpreadAttribute(node, opts)。
AST 节点 JSXSpreadAttribute 的结构:
argument:Expression(必填)
别名: JSX
jsxSpreadChild
t.jsxSpreadChild(expression);
另请参阅 t.isJSXSpreadChild(node, opts) 和 t.assertJSXSpreadChild(node, opts)。
AST 节点 JSXSpreadChild 的结构:
expression:Expression(必需)
jsxText
t.jsxText(value);
另请参阅 t.isJSXText(node, opts) 和 t.assertJSXText(node, opts)。
AST 节点 JSXText 的结构:
value:string(required)
labeledStatement
t.labeledStatement(label, body);
另请参阅 t.isLabeledStatement(node, opts) 和 t.assertLabeledStatement(node, opts)。
AST 节点 LabeledStatement 的结构:
-
label:Identifier(必填) -
body:Statement(必需)
别名: Standardized, Statement
logicalExpression
t.logicalExpression(operator, left, right);
另见 t.isLogicalExpression(node, opts) 和 t.assertLogicalExpression(node, opts)。
AST 节点 LogicalExpression 的结构:
-
operator:"||" | "&&" | "??"(必需) -
left:Expression(必需) -
right:Expression(必需)
别名: Standardized, Binary, Expression
memberExpression
t.memberExpression(object, property, computed, optional);
另见 t.isMemberExpression(node, opts) 和 t.assertMemberExpression(node, opts)。
AST 节点 MemberExpression 的结构:
-
object:Expression | Super(必需) -
property: 若为计算属性则需Expression,否则需Identifier(必需) -
computed:boolean(默认值:false) -
optional:boolean(默认值:null)
别名: Standardized, Expression, LVal, PatternLike
metaProperty
t.metaProperty(meta, property);
另见 t.isMetaProperty(node, opts) 和 t.assertMetaProperty(node, opts)。
AST 节点 MetaProperty 的结构:
-
meta:Identifier(必需) -
property:Identifier(必需)
mixedTypeAnnotation
t.mixedTypeAnnotation();
另见 t.isMixedTypeAnnotation(node, opts) 和 t.assertMixedTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
moduleExpression
t.moduleExpression(body);
另见 t.isModuleExpression(node, opts) 和 t.assertModuleExpression(node, opts)。
AST 节点 ModuleExpression 的结构:
body:Program(必需)
别名:Expression
newExpression
t.newExpression(callee, arguments);
另见 t.isNewExpression(node, opts) 和 t.assertNewExpression(node, opts)。
AST 节点 NewExpression 的结构:
-
callee:Expression | Super | V8IntrinsicIdentifier(必需) -
arguments:(Expression | SpreadElement | ArgumentPlaceholder)[](必需) -
optional:boolean(默认值:null,不包含在构建器函数中) -
typeArguments:TypeParameterInstantiation(默认值:null,不包含在构建器函数中) -
typeParameters:TSTypeParameterInstantiation(默认值:null,不包含在构建器函数中)
noop
t.noop();
参见 t.isNoop(node, opts) 和 t.assertNoop(node, opts)。
nullLiteral
t.nullLiteral();
参见 t.isNullLiteral(node, opts) 和 t.assertNullLiteral(node, opts)。
别名:Standardized, Expression, Pureish, Literal, Immutable
nullLiteralTypeAnnotation
t.nullLiteralTypeAnnotation();
参见 t.isNullLiteralTypeAnnotation(node, opts) 和 t.assertNullLiteralTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
nullableTypeAnnotation
t.nullableTypeAnnotation(typeAnnotation);
参见 t.isNullableTypeAnnotation(node, opts) 和 t.assertNullableTypeAnnotation(node, opts)。
AST节点 NullableTypeAnnotation 结构:
typeAnnotation:FlowType(必需)
numberLiteralTypeAnnotation
t.numberLiteralTypeAnnotation(value);
参见 t.isNumberLiteralTypeAnnotation(node, opts) 和 t.assertNumberLiteralTypeAnnotation(node, opts)。
AST节点 NumberLiteralTypeAnnotation 结构:
value:number(必需)
numberTypeAnnotation
t.numberTypeAnnotation();
参见 t.isNumberTypeAnnotation(node, opts) 和 t.assertNumberTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
numericLiteral
t.numericLiteral(value);
参见 t.isNumericLiteral(node, opts) 和 t.assertNumericLiteral(node, opts)。
AST节点 NumericLiteral 结构:
value: 非负有限number(必需)
别名:Standardized, Expression, Pureish, Literal, Immutable
objectExpression
t.objectExpression(properties);
参见 t.isObjectExpression(node, opts) 和 t.assertObjectExpression(node, opts)。
AST节点 ObjectExpression 结构:
properties:(ObjectMethod | ObjectProperty | SpreadElement)[](必需)
objectMethod
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: 如果是计算属性则为Expression,否则为Identifier | Literal(必需) -
params:FunctionParameter[](必需) -
body:BlockStatement(必需) -
computed:boolean(默认值:false) -
generator:boolean(默认值:false) -
async:boolean(默认值:false) -
decorators:Decorator[](默认值:null,不包含在构建器函数中) -
returnType:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,不包含在构建函数中) -
typeParameters:TypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认值:null,不包含在构建函数中)
别名:Standardized、UserWhitespacable、Function、Scopable、BlockParent、FunctionParent、Method、ObjectMember
objectPattern
t.objectPattern(properties);
另请参见 t.isObjectPattern(node, opts) 和 t.assertObjectPattern(node, opts)。
AST 节点 ObjectPattern 的结构:
-
properties:(RestElement | ObjectProperty)[](必需) -
decorators:Decorator[](默认值:null,不包含在构建器函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(default:null, 不包含在构建器函数中)
别名:Standardized、FunctionParameter、Pattern、PatternLike、LVal
objectProperty
t.objectProperty(key, value, computed, shorthand, decorators);
另请参见 t.isObjectProperty(node, opts) 和 t.assertObjectProperty(node, opts)。
AST 节点 ObjectProperty 的结构:
-
key: 如果是计算属性则为Expression,否则为Identifier | Literal(必需) -
value:Expression | PatternLike(必需) -
computed:boolean(默认值:false) -
shorthand:boolean(默认值:false) -
decorators:Decorator[](默认值:null)
别名:Standardized、UserWhitespacable、Property、ObjectMember
objectTypeAnnotation
t.objectTypeAnnotation(properties, indexers, callProperties, internalSlots, exact);
另请参见 t.isObjectTypeAnnotation(node, opts) 和 t.assertObjectTypeAnnotation(node, opts)。
AST 节点 ObjectTypeAnnotation 的结构:
-
properties:(ObjectTypeProperty | ObjectTypeSpreadProperty)[](必需) -
indexers:ObjectTypeIndexer[](默认值:[]) -
callProperties:ObjectTypeCallProperty[](默认值:[]) -
internalSlots:ObjectTypeInternalSlot[](默认值:[]) -
exact:boolean(默认值:false) -
inexact:boolean(默认值:null,不包含在构建函数中)
objectTypeCallProperty
t.objectTypeCallProperty(value);
另请参见 t.isObjectTypeCallProperty(node, opts) 和 t.assertObjectTypeCallProperty(node, opts)。
AST 节点 ObjectTypeCallProperty 的结构:
-
value:FlowType(必需) -
static:boolean(必需)
objectTypeIndexer
t.objectTypeIndexer(id, key, value, variance);
另见 t.isObjectTypeIndexer(node, opts) 和 t.assertObjectTypeIndexer(node, opts)。
AST 节点 ObjectTypeIndexer 的结构:
-
id:Identifier(默认值:null) -
key:FlowType(必需) -
value:FlowType(必需) -
variance:Variance(默认值:null) -
static:boolean(必需)
objectTypeInternalSlot
t.objectTypeInternalSlot(id, value, optional, static, method);
另见 t.isObjectTypeInternalSlot(node, opts) 和 t.assertObjectTypeInternalSlot(node, opts)。
AST 节点 ObjectTypeInternalSlot 的结构:
-
id:Identifier(必需) -
value:FlowType(必需) -
optional:boolean(必须) -
static:boolean(必需) -
method:boolean(必需)
objectTypeProperty
t.objectTypeProperty(key, value, variance);
另见 t.isObjectTypeProperty(node, opts) 和 t.assertObjectTypeProperty(node, opts)。
AST 节点 ObjectTypeProperty 的结构:
-
key:Identifier | StringLiteral(必需) -
value:FlowType(必需) -
variance:Variance(默认值:null) -
kind:"init" | "get" | "set"(必需) -
method:boolean(必需) -
optional:boolean(必须) -
proto:boolean(必需) -
static:boolean(必需)
objectTypeSpreadProperty
t.objectTypeSpreadProperty(argument);
另见 t.isObjectTypeSpreadProperty(node, opts) 和 t.assertObjectTypeSpreadProperty(node, opts)。
AST 节点 ObjectTypeSpreadProperty 的结构:
argument:FlowType(必填)
opaqueType
t.opaqueType(id, typeParameters, supertype, impltype);
另见 t.isOpaqueType(node, opts) 和 t.assertOpaqueType(node, opts)。
AST 节点 OpaqueType 的结构:
-
id:Identifier(必需) -
typeParameters:TypeParameterDeclaration(默认值:null) -
supertype:FlowType(默认:null) -
impltype:FlowType(必须)
别名:Flow, FlowDeclaration, Statement, Declaration
optionalCallExpression
t.optionalCallExpression(callee, arguments, optional);
另请参阅 t.isOptionalCallExpression(node, opts) 和 t.assertOptionalCallExpression(node, opts)。
AST 节点 OptionalCallExpression 结构:
-
callee:Expression(必须) -
arguments:(Expression | SpreadElement | ArgumentPlaceholder)[](必需) -
optional:boolean(必须) -
typeArguments:TypeParameterInstantiation(默认值:null,不包含在构建器函数中) -
typeParameters:TSTypeParameterInstantiation(默认值:null,不包含在构建器函数中)
optionalIndexedAccessType
t.optionalIndexedAccessType(objectType, indexType);
另请参阅 t.isOptionalIndexedAccessType(node, opts) 和 t.assertOptionalIndexedAccessType(node, opts)。
AST 节点 OptionalIndexedAccessType 结构:
-
objectType:FlowType(必须) -
indexType:FlowType(必须) -
optional:boolean(必须)
optionalMemberExpression
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(必须)
parenthesizedExpression
t.parenthesizedExpression(expression);
另请参阅 t.isParenthesizedExpression(node, opts) 和 t.assertParenthesizedExpression(node, opts)。
AST 节点 ParenthesizedExpression 结构:
expression:Expression(必需)
别名:Standardized、Expression、ExpressionWrapper
pipelineBareFunction
t.pipelineBareFunction(callee);
另请参阅 t.isPipelineBareFunction(node, opts) 和 t.assertPipelineBareFunction(node, opts)。
AST 节点 PipelineBareFunction 结构:
callee:Expression(必须)
别名:Expression
pipelinePrimaryTopicReference
t.pipelinePrimaryTopicReference();
另请参阅 t.isPipelinePrimaryTopicReference(node, opts) 和 t.assertPipelinePrimaryTopicReference(node, opts)。
别名:Expression
pipelineTopicExpression
t.pipelineTopicExpression(expression);
另请参阅 t.isPipelineTopicExpression(node, opts) 和 t.assertPipelineTopicExpression(node, opts)。
AST 节点 PipelineTopicExpression 结构:
expression:Expression(必需)
别名:Expression
placeholder
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(必须) -
decorators:Decorator[](默认值:null,不包含在构建器函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(default:null, 不包含在构建器函数中)
privateName
t.privateName(id);
另请参阅 t.isPrivateName(node, opts) 和 t.assertPrivateName(node, opts)。
AST 节点 PrivateName 的结构:
id:Identifier(必需)
别名:Standardized, Private
program
t.program(body, directives, sourceType, interpreter);
另请参阅 t.isProgram(node, opts) 和 t.assertProgram(node, opts)。
AST 节点 Program 的结构:
-
body:Statement[](必需) -
directives:Directive[](默认值:[]) -
sourceType:"script" | "module"(默认值:'script') -
interpreter:InterpreterDirective(默认值:null)
别名:Standardized, Scopable, BlockParent, Block
qualifiedTypeIdentifier
t.qualifiedTypeIdentifier(id, qualification);
另请参阅 t.isQualifiedTypeIdentifier(node, opts) 和 t.assertQualifiedTypeIdentifier(node, opts)。
AST 节点 QualifiedTypeIdentifier 的结构:
-
id:Identifier(必需) -
qualification:Identifier | QualifiedTypeIdentifier(必须)
别名: Flow
recordExpression
t.recordExpression(properties);
另请参阅 t.isRecordExpression(node, opts) 和 t.assertRecordExpression(node, opts)。
AST 节点 RecordExpression 的结构:
properties:(ObjectProperty | SpreadElement)[](必需)
别名:Expression
regExpLiteral
t.regExpLiteral(pattern, flags);
另请参阅 t.isRegExpLiteral(node, opts) 和 t.assertRegExpLiteral(node, opts)。
AST 节点 RegExpLiteral 的结构:
-
pattern:string(必须) -
flags:string(默认值:'')
别名:Standardized, Expression, Pureish, Literal
restElement
t.restElement(argument);
另请参阅 t.isRestElement(node, opts) 和 t.assertRestElement(node, opts)。
AST 节点 RestElement 的结构:
-
argument:Identifier | ArrayPattern | ObjectPattern | MemberExpression | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | RestElement | AssignmentPattern(required) -
decorators:Decorator[](默认值:null,不包含在构建器函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(default:null, 不包含在构建器函数中)
别名:Standardized, FunctionParameter, PatternLike, LVal
returnStatement
t.returnStatement(argument);
另请参阅 t.isReturnStatement(node, opts) 和 t.assertReturnStatement(node, opts)。
AST 节点 ReturnStatement 的结构:
argument:Expression(默认值:null)
别名:Standardized, Statement, Terminatorless, CompletionStatement
sequenceExpression
t.sequenceExpression(expressions);
另请参阅 t.isSequenceExpression(node, opts) 和 t.assertSequenceExpression(node, opts)。
AST 节点 SequenceExpression 的结构:
expressions:Expression[](必需)
spreadElement
t.spreadElement(argument);
另请参阅 t.isSpreadElement(node, opts) 和 t.assertSpreadElement(node, opts)。
AST 节点 SpreadElement 的结构:
argument:Expression(必填)
staticBlock
t.staticBlock(body);
另请参阅 t.isStaticBlock(node, opts) 和 t.assertStaticBlock(node, opts)。
AST 节点 StaticBlock 的结构:
body:Statement[](必需)
别名:Standardized, Scopable, BlockParent, FunctionParent
stringLiteral
t.stringLiteral(value);
另请参阅 t.isStringLiteral(node, opts) 和 t.assertStringLiteral(node, opts)。
AST 节点 StringLiteral 的结构:
value:string(required)
别名:Standardized, Expression, Pureish, Literal, Immutable
stringLiteralTypeAnnotation
t.stringLiteralTypeAnnotation(value);
另请参阅 t.isStringLiteralTypeAnnotation(node, opts) 和 t.assertStringLiteralTypeAnnotation(node, opts)。
AST 节点 StringLiteralTypeAnnotation 的结构:
value:string(required)
stringTypeAnnotation
t.stringTypeAnnotation();
另见 t.isStringTypeAnnotation(node, opts) 和 t.assertStringTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
super
t.super();
另见 t.isSuper(node, opts) 和 t.assertSuper(node, opts)。
switchCase
t.switchCase(test, consequent);
另见 t.isSwitchCase(node, opts) 和 t.assertSwitchCase(node, opts)。
AST 节点 SwitchCase 结构:
-
test:Expression(默认值:null) -
consequent:Statement[](必需)
别名: Standardized
switchStatement
t.switchStatement(discriminant, cases);
另见 t.isSwitchStatement(node, opts) 和 t.assertSwitchStatement(node, opts)。
AST 节点 SwitchStatement 结构:
-
discriminant:Expression(必需) -
cases:SwitchCase[](必需)
别名:Standardized, Statement, BlockParent, Scopable
symbolTypeAnnotation
t.symbolTypeAnnotation();
另见 t.isSymbolTypeAnnotation(node, opts) 和 t.assertSymbolTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
tsAnyKeyword
t.tsAnyKeyword();
另见 t.isTSAnyKeyword(node, opts) 和 t.assertTSAnyKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsArrayType
t.tsArrayType(elementType);
另见 t.isTSArrayType(node, opts) 和 t.assertTSArrayType(node, opts)。
AST 节点 TSArrayType 结构:
elementType:TSType(必填)
别名:TypeScript, TSType
tsAsExpression
t.tsAsExpression(expression, typeAnnotation);
另见 t.isTSAsExpression(node, opts) 和 t.assertTSAsExpression(node, opts)。
AST 节点 TSAsExpression 结构:
-
expression:Expression(必需) -
typeAnnotation:TSType(必填)
别名: TypeScript, Expression, LVal, PatternLike
tsBigIntKeyword
t.tsBigIntKeyword();
另见 t.isTSBigIntKeyword(node, opts) 和 t.assertTSBigIntKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsBooleanKeyword
t.tsBooleanKeyword();
另请参阅 t.isTSBooleanKeyword(node, opts) 和 t.assertTSBooleanKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsCallSignatureDeclaration
t.tsCallSignatureDeclaration(typeParameters, parameters, typeAnnotation);
另请参阅 t.isTSCallSignatureDeclaration(node, opts) 和 t.assertTSCallSignatureDeclaration(node, opts)。
AST 节点 TSCallSignatureDeclaration 的结构:
-
typeParameters:TSTypeParameterDeclaration(默认值:null) -
parameters:(ArrayPattern | Identifier | ObjectPattern | RestElement)[](必需) -
typeAnnotation:TSTypeAnnotation(默认值:null)
tsConditionalType
t.tsConditionalType(checkType, extendsType, trueType, falseType);
另请参阅 t.isTSConditionalType(node, opts) 和 t.assertTSConditionalType(node, opts)。
AST 节点 TSConditionalType 的结构:
-
checkType:TSType(必需) -
extendsType:TSType(必需) -
trueType:TSType(必需) -
falseType:TSType(必需)
别名:TypeScript, TSType
tsConstructSignatureDeclaration
t.tsConstructSignatureDeclaration(typeParameters, parameters, typeAnnotation);
另请参阅 t.isTSConstructSignatureDeclaration(node, opts) 和 t.assertTSConstructSignatureDeclaration(node, opts)。
AST 节点 TSConstructSignatureDeclaration 的结构:
-
typeParameters:TSTypeParameterDeclaration(默认值:null) -
parameters:(ArrayPattern | Identifier | ObjectPattern | RestElement)[](必需) -
typeAnnotation:TSTypeAnnotation(默认值:null)
tsConstructorType
t.tsConstructorType(typeParameters, parameters, typeAnnotation);
另请参阅 t.isTSConstructorType(node, opts) 和 t.assertTSConstructorType(node, opts)。
AST 节点 TSConstructorType 的结构:
-
typeParameters:TSTypeParameterDeclaration(默认值:null) -
parameters:(ArrayPattern | Identifier | ObjectPattern | RestElement)[](必需) -
typeAnnotation:TSTypeAnnotation(默认值:null) -
abstract:boolean(默认值:null,不包含在构建函数中)
别名:TypeScript, TSType
tsDeclareFunction
t.tsDeclareFunction(id, typeParameters, params, returnType);
另请参阅 t.isTSDeclareFunction(node, opts) 和 t.assertTSDeclareFunction(node, opts)。
AST 节点 TSDeclareFunction 的结构:
-
id:Identifier(默认值:null) -
typeParameters:TSTypeParameterDeclaration | Noop(默认值:null) -
params:FunctionParameter[](必需) -
returnType:TSTypeAnnotation | Noop(默认值:null) -
async:boolean(默认值:false,不包含在构建函数中) -
declare:boolean(默认:null, 构建函数中排除) -
generator:boolean(默认值:false,不包含在构建函数中)
别名: TypeScript, Statement, Declaration
tsDeclareMethod
t.tsDeclareMethod(decorators, key, typeParameters, params, returnType);
另请参阅 t.isTSDeclareMethod(node, opts) 和 t.assertTSDeclareMethod(node, opts)。
AST 节点 TSDeclareMethod 的结构:
-
decorators:Decorator[](默认值:null) -
key:Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression(必需) -
typeParameters:TSTypeParameterDeclaration | Noop(默认值:null) -
params:(FunctionParameter | TSParameterProperty)[](必需) -
returnType:TSTypeAnnotation | Noop(默认值:null) -
abstract:boolean(默认值:null,不包含在构建函数中) -
access:"public" | "private" | "protected"(默认值:null,不包含在构建函数中) -
accessibility:"public" | "private" | "protected"(默认值:null,不包含在构建器函数中) -
async:boolean(默认值:false,不包含在构建函数中) -
computed:boolean(默认值:false,不包含在构建器函数中) -
generator:boolean(默认值:false,不包含在构建函数中) -
kind:"get" | "set" | "method" | "constructor"(默认值:'method',不包含在构建函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
override:boolean(默认值:false,不包含在构建函数中) -
static:boolean(默认值:false,不包含在构建函数中)
别名:TypeScript
tsEnumBody
t.tsEnumBody(members);
另请参阅 t.isTSEnumBody(node, opts) 和 t.assertTSEnumBody(node, opts)。
AST 节点 TSEnumBody 的结构:
members:TSEnumMember[](必需)
别名:TypeScript
tsEnumDeclaration
t.tsEnumDeclaration(id, members);
另请参阅 t.isTSEnumDeclaration(node, opts) 和 t.assertTSEnumDeclaration(node, opts)。
AST 节点 TSEnumDeclaration 的结构:
-
id:Identifier(必需) -
members:TSEnumMember[](必需) -
body:TSEnumBody(默认值:null,不包含在构建函数中) -
const:boolean(默认值:null, 构建器函数中排除) -
declare:boolean(默认:null, 构建函数中排除) -
initializer:Expression(默认值:null,不包含在构建函数中)
别名: TypeScript, Statement, Declaration
tsEnumMember
t.tsEnumMember(id, initializer);
另见 t.isTSEnumMember(node, opts) 和 t.assertTSEnumMember(node, opts)。
AST 节点 TSEnumMember 的结构:
-
id:Identifier | StringLiteral(必填) -
initializer:Expression(默认值:null)
别名:TypeScript
tsExportAssignment
t.tsExportAssignment(expression);
另见 t.isTSExportAssignment(node, opts) 和 t.assertTSExportAssignment(node, opts)。
AST 节点 TSExportAssignment 的结构:
expression:Expression(必需)
tsExpressionWithTypeArguments
t.tsExpressionWithTypeArguments(expression, typeParameters);
另见 t.isTSExpressionWithTypeArguments(node, opts) 和 t.assertTSExpressionWithTypeArguments(node, opts)。
AST 节点 TSExpressionWithTypeArguments 的结构:
-
expression:TSEntityName(必需) -
typeParameters:TSTypeParameterInstantiation(默认值:null)
别名:TypeScript, TSType
tsExternalModuleReference
t.tsExternalModuleReference(expression);
另见 t.isTSExternalModuleReference(node, opts) 和 t.assertTSExternalModuleReference(node, opts)。
AST 节点 TSExternalModuleReference 的结构:
expression:StringLiteral(必需)
别名:TypeScript
tsFunctionType
t.tsFunctionType(typeParameters, parameters, typeAnnotation);
另见 t.isTSFunctionType(node, opts) 和 t.assertTSFunctionType(node, opts)。
AST 节点 TSFunctionType 的结构:
-
typeParameters:TSTypeParameterDeclaration(默认值:null) -
parameters:(ArrayPattern | Identifier | ObjectPattern | RestElement)[](必需) -
typeAnnotation:TSTypeAnnotation(默认值:null)
别名:TypeScript, TSType
tsImportEqualsDeclaration
t.tsImportEqualsDeclaration(id, moduleReference);
另见 t.isTSImportEqualsDeclaration(node, opts) 和 t.assertTSImportEqualsDeclaration(node, opts)。
AST 节点 TSImportEqualsDeclaration 的结构:
-
id:Identifier(必需) -
moduleReference:TSEntityName | TSExternalModuleReference(必需) -
importKind:"type" | "value"(默认值:null, 不包含在构建器函数中) -
isExport:boolean(必需)
别名: TypeScript, Statement, Declaration
tsImportType
t.tsImportType(argument, qualifier, typeParameters);
另见 t.isTSImportType(node, opts) 和 t.assertTSImportType(node, opts)。
AST 节点 TSImportType 的结构:
-
argument:StringLiteral(必须) -
qualifier:TSEntityName(默认值:null) -
typeParameters:TSTypeParameterInstantiation(默认值:null) -
options:ObjectExpression(默认值:null, 不包含在构建函数中)
别名:TypeScript, TSType
tsIndexSignature
t.tsIndexSignature(parameters, typeAnnotation);
另请参阅 t.isTSIndexSignature(node, opts) 和 t.assertTSIndexSignature(node, opts)。
AST 节点 TSIndexSignature 的结构:
-
parameters:Identifier[](必需) -
typeAnnotation:TSTypeAnnotation(默认值:null) -
readonly:boolean(默认值:null,不包含在构建器函数中) -
static:boolean(默认值:null, 不包含在构建函数中)
tsIndexedAccessType
t.tsIndexedAccessType(objectType, indexType);
另请参阅 t.isTSIndexedAccessType(node, opts) 和 t.assertTSIndexedAccessType(node, opts)。
AST 节点 TSIndexedAccessType 的结构:
-
objectType:TSType(必须) -
indexType:TSType(必须)
别名:TypeScript, TSType
tsInferType
t.tsInferType(typeParameter);
另请参阅 t.isTSInferType(node, opts) 和 t.assertTSInferType(node, opts)。
AST 节点 TSInferType 的结构:
typeParameter:TSTypeParameter(必填)
别名:TypeScript, TSType
tsInstantiationExpression
t.tsInstantiationExpression(expression, typeParameters);
另请参阅 t.isTSInstantiationExpression(node, opts) 和 t.assertTSInstantiationExpression(node, opts)。
AST 节点 TSInstantiationExpression 的结构:
-
expression:Expression(必需) -
typeParameters:TSTypeParameterInstantiation(默认值:null)
别名:TypeScript, Expression
tsInterfaceBody
t.tsInterfaceBody(body);
另请参阅 t.isTSInterfaceBody(node, opts) 和 t.assertTSInterfaceBody(node, opts)。
AST 节点 TSInterfaceBody 的结构:
body:TSTypeElement[](必需)
别名:TypeScript
tsInterfaceDeclaration
t.tsInterfaceDeclaration(id, typeParameters, extends, body);
另请参阅 t.isTSInterfaceDeclaration(node, opts) 和 t.assertTSInterfaceDeclaration(node, opts)。
AST 节点 TSInterfaceDeclaration 的结构:
-
id:Identifier(必需) -
typeParameters:TSTypeParameterDeclaration(默认值:null) -
extends:TSExpressionWithTypeArguments[](默认值:null) -
body:TSInterfaceBody(必填) -
declare:boolean(默认:null, 构建函数中排除)
别名: TypeScript, Statement, Declaration
tsIntersectionType
t.tsIntersectionType(types);
另请参阅 t.isTSIntersectionType(node, opts) 和 t.assertTSIntersectionType(node, opts)。
AST 节点 TSIntersectionType 结构:
types:TSType[](必需)
别名:TypeScript, TSType
tsIntrinsicKeyword
t.tsIntrinsicKeyword();
另请参阅 t.isTSIntrinsicKeyword(node, opts) 和 t.assertTSIntrinsicKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsLiteralType
t.tsLiteralType(literal);
另请参阅 t.isTSLiteralType(node, opts) 和 t.assertTSLiteralType(node, opts)。
AST 节点 TSLiteralType 结构:
literal:NumericLiteral | StringLiteral | BooleanLiteral | BigIntLiteral | TemplateLiteral | UnaryExpression(必填)
别名:TypeScript, TSType, TSBaseType
tsMappedType
t.tsMappedType(typeParameter, typeAnnotation, nameType);
另请参阅 t.isTSMappedType(node, opts) 和 t.assertTSMappedType(node, opts)。
AST 节点 TSMappedType 结构:
-
typeParameter:TSTypeParameter(必填) -
typeAnnotation:TSType(默认值:null) -
nameType:TSType(默认值:null) -
optional:true | false | "+" | "-"(默认值:null, 不包含在构建函数中) -
readonly:true | false | "+" | "-"(默认值:null, 不包含在构建函数中)
别名:TypeScript, TSType
tsMethodSignature
t.tsMethodSignature(key, typeParameters, parameters, typeAnnotation);
另请参阅 t.isTSMethodSignature(node, opts) 和 t.assertTSMethodSignature(node, opts)。
AST 节点 TSMethodSignature 结构:
-
key:Expression(必需) -
typeParameters:TSTypeParameterDeclaration(默认值:null) -
parameters:(ArrayPattern | Identifier | ObjectPattern | RestElement)[](必需) -
typeAnnotation:TSTypeAnnotation(默认值:null) -
computed:boolean(默认值:false,不包含在构建器函数中) -
kind:"method" | "get" | "set"(必填) -
optional:boolean(默认值:null,不包含在构建器函数中)
tsModuleBlock
t.tsModuleBlock(body);
另请参阅 t.isTSModuleBlock(node, opts) 和 t.assertTSModuleBlock(node, opts)。
AST 节点 TSModuleBlock 结构:
body:Statement[](必需)
别名:TypeScript、Scopable、Block、BlockParent、FunctionParent
tsModuleDeclaration
t.tsModuleDeclaration(id, body);
另请参阅 t.isTSModuleDeclaration(node, opts) 和 t.assertTSModuleDeclaration(node, opts)。
AST 节点 TSModuleDeclaration 结构:
-
id:Identifier | StringLiteral(必填) -
body:TSModuleBlock | TSModuleDeclaration(必填) -
declare:boolean(默认:null, 构建函数中排除) -
global:boolean(默认:null,构建函数中不包含) -
kind:"global" | "module" | "namespace"(必填)
别名: TypeScript, Statement, Declaration
tsNamedTupleMember
t.tsNamedTupleMember(label, elementType, optional);
另请参阅 t.isTSNamedTupleMember(node, opts) 和 t.assertTSNamedTupleMember(node, opts)。
AST 节点 TSNamedTupleMember 结构:
-
label:Identifier(必填) -
elementType:TSType(必填) -
optional:boolean(默认:false)
别名:TypeScript
tsNamespaceExportDeclaration
t.tsNamespaceExportDeclaration(id);
另请参阅 t.isTSNamespaceExportDeclaration(node, opts) 和 t.assertTSNamespaceExportDeclaration(node, opts)。
AST 节点 TSNamespaceExportDeclaration 结构:
id:Identifier(必需)
tsNeverKeyword
t.tsNeverKeyword();
另请参阅 t.isTSNeverKeyword(node, opts) 和 t.assertTSNeverKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsNonNullExpression
t.tsNonNullExpression(expression);
另请参阅 t.isTSNonNullExpression(node, opts) 和 t.assertTSNonNullExpression(node, opts)。
AST 节点 TSNonNullExpression 结构:
expression:Expression(必需)
别名: TypeScript, Expression, LVal, PatternLike
tsNullKeyword
t.tsNullKeyword();
另请参阅 t.isTSNullKeyword(node, opts) 和 t.assertTSNullKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsNumberKeyword
t.tsNumberKeyword();
另请参阅 t.isTSNumberKeyword(node, opts) 和 t.assertTSNumberKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsObjectKeyword
t.tsObjectKeyword();
另见 t.isTSObjectKeyword(node, opts) 和 t.assertTSObjectKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsOptionalType
t.tsOptionalType(typeAnnotation);
另见 t.isTSOptionalType(node, opts) 和 t.assertTSOptionalType(node, opts)。
AST 节点 TSOptionalType 结构:
typeAnnotation:TSType(必填)
别名:TypeScript, TSType
tsParameterProperty
t.tsParameterProperty(parameter);
另见 t.isTSParameterProperty(node, opts) 和 t.assertTSParameterProperty(node, opts)。
AST 节点 TSParameterProperty 结构:
-
parameter:Identifier | AssignmentPattern(必需) -
accessibility:"public" | "private" | "protected"(默认值:null,不包含在构建器函数中) -
decorators:Decorator[](默认值:null,不包含在构建器函数中) -
override:boolean(默认值:null,不包含在构建器函数中) -
readonly:boolean(默认值:null,不包含在构建器函数中)
别名:TypeScript、LVal
tsParenthesizedType
t.tsParenthesizedType(typeAnnotation);
另见 t.isTSParenthesizedType(node, opts) 和 t.assertTSParenthesizedType(node, opts)。
AST 节点 TSParenthesizedType 结构:
typeAnnotation:TSType(必填)
别名:TypeScript, TSType
tsPropertySignature
t.tsPropertySignature(key, typeAnnotation);
另见 t.isTSPropertySignature(node, opts) 和 t.assertTSPropertySignature(node, opts)。
AST 节点 TSPropertySignature 结构:
-
key:Expression(必需) -
typeAnnotation:TSTypeAnnotation(默认值:null) -
computed:boolean(默认值:false,不包含在构建器函数中) -
kind:"get" | "set"(默认值:null,不包含在构建器函数中) -
optional:boolean(默认值:null,不包含在构建器函数中) -
readonly:boolean(默认值:null,不包含在构建器函数中)
tsQualifiedName
t.tsQualifiedName(left, right);
另见 t.isTSQualifiedName(node, opts) 和 t.assertTSQualifiedName(node, opts)。
AST 节点 TSQualifiedName 结构:
-
left:TSEntityName(必需) -
right:Identifier(必需)
tsRestType
t.tsRestType(typeAnnotation);
另请参见 t.isTSRestType(node, opts) 和 t.assertTSRestType(node, opts)。
AST 节点 TSRestType 结构:
typeAnnotation:TSType(必填)
别名:TypeScript, TSType
tsSatisfiesExpression
t.tsSatisfiesExpression(expression, typeAnnotation);
History
| Version | Changes |
|---|---|
v7.20.0 | Introduced |
另请参见 t.isTSSatisfiesExpression(node, opts) 和 t.assertTSSatisfiesExpression(node, opts)。
AST 节点 TSSatisfiesExpression 结构:
-
expression:Expression(必需) -
typeAnnotation:TSType(必填)
别名: TypeScript, Expression, LVal, PatternLike
tsStringKeyword
t.tsStringKeyword();
另请参见 t.isTSStringKeyword(node, opts) 和 t.assertTSStringKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsSymbolKeyword
t.tsSymbolKeyword();
另请参见 t.isTSSymbolKeyword(node, opts) 和 t.assertTSSymbolKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsTemplateLiteralType
t.tsTemplateLiteralType(quasis, types);
另请参见 t.isTSTemplateLiteralType(node, opts) 和 t.assertTSTemplateLiteralType(node, opts)。
AST 节点 TSTemplateLiteralType 结构:
-
quasis:TemplateElement[](必需) -
types:TSType[](必需)
别名:TypeScript, TSType, TSBaseType
tsThisType
t.tsThisType();
另请参见 t.isTSThisType(node, opts) 和 t.assertTSThisType(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsTupleType
t.tsTupleType(elementTypes);
另请参见 t.isTSTupleType(node, opts) 和 t.assertTSTupleType(node, opts)。
AST 节点 TSTupleType 结构:
elementTypes:(TSType | TSNamedTupleMember)[](必需)
别名:TypeScript, TSType
tsTypeAliasDeclaration
t.tsTypeAliasDeclaration(id, typeParameters, typeAnnotation);
另请参见 t.isTSTypeAliasDeclaration(node, opts) 和 t.assertTSTypeAliasDeclaration(node, opts)。
AST 节点 TSTypeAliasDeclaration 结构:
-
id:Identifier(必需) -
typeParameters:TSTypeParameterDeclaration(默认值:null) -
typeAnnotation:TSType(必填) -
declare:boolean(默认:null, 构建函数中排除)
别名: TypeScript, Statement, Declaration
tsTypeAnnotation
t.tsTypeAnnotation(typeAnnotation);
另见 t.isTSTypeAnnotation(node, opts) 和 t.assertTSTypeAnnotation(node, opts)。
AST 节点 TSTypeAnnotation 结构:
typeAnnotation:TSType(必填)
别名:TypeScript
tsTypeAssertion
t.tsTypeAssertion(typeAnnotation, expression);
另见 t.isTSTypeAssertion(node, opts) 和 t.assertTSTypeAssertion(node, opts)。
AST 节点 TSTypeAssertion 结构:
-
typeAnnotation:TSType(必填) -
expression:Expression(必需)
别名: TypeScript, Expression, LVal, PatternLike
tsTypeLiteral
t.tsTypeLiteral(members);
另见 t.isTSTypeLiteral(node, opts) 和 t.assertTSTypeLiteral(node, opts)。
AST 节点 TSTypeLiteral 结构:
members:TSTypeElement[](必需)
别名:TypeScript, TSType
tsTypeOperator
t.tsTypeOperator(typeAnnotation, operator);
另见 t.isTSTypeOperator(node, opts) 和 t.assertTSTypeOperator(node, opts)。
AST 节点 TSTypeOperator 结构:
-
typeAnnotation:TSType(必填) -
operator:string(默认值:'keyof')
别名:TypeScript, TSType
tsTypeParameter
t.tsTypeParameter(constraint, default, name);
History
| Version | Changes |
|---|---|
v7.21.0 | Supports const |
另见 t.isTSTypeParameter(node, opts) 和 t.assertTSTypeParameter(node, opts)。
AST 节点 TSTypeParameter 结构:
-
constraint:TSType(默认值:null) -
default:TSType(默认值:null) -
name:string(必填) -
const:boolean(默认值:null, 构建器函数中排除) -
in:boolean(默认值:null, 构建器函数中排除) -
out:boolean(默认值:null, 构建器函数中排除)
别名:TypeScript
tsTypeParameterDeclaration
t.tsTypeParameterDeclaration(params);
另见 t.isTSTypeParameterDeclaration(node, opts) 和 t.assertTSTypeParameterDeclaration(node, opts)。
AST 节点 TSTypeParameterDeclaration 结构:
params:TSTypeParameter[](必需)
别名:TypeScript
tsTypeParameterInstantiation
t.tsTypeParameterInstantiation(params);
另请参阅 t.isTSTypeParameterInstantiation(node, opts) 和 t.assertTSTypeParameterInstantiation(node, opts)。
AST 节点 TSTypeParameterInstantiation 的结构:
params:TSType[](必需)
别名:TypeScript
tsTypePredicate
t.tsTypePredicate(parameterName, typeAnnotation, asserts);
另请参阅 t.isTSTypePredicate(node, opts) 和 t.assertTSTypePredicate(node, opts)。
AST 节点 TSTypePredicate 的结构:
-
parameterName:Identifier | TSThisType(必填) -
typeAnnotation:TSTypeAnnotation(默认值:null) -
asserts:boolean(默认值:null)
别名:TypeScript, TSType
tsTypeQuery
t.tsTypeQuery(exprName, typeParameters);
另请参阅 t.isTSTypeQuery(node, opts) 和 t.assertTSTypeQuery(node, opts)。
AST 节点 TSTypeQuery 的结构:
-
exprName:TSEntityName | TSImportType(必填) -
typeParameters:TSTypeParameterInstantiation(默认值:null)
别名:TypeScript, TSType
tsTypeReference
t.tsTypeReference(typeName, typeParameters);
另请参阅 t.isTSTypeReference(node, opts) 和 t.assertTSTypeReference(node, opts)。
AST 节点 TSTypeReference 的结构:
-
typeName:TSEntityName(必填) -
typeParameters:TSTypeParameterInstantiation(默认值:null)
别名:TypeScript, TSType
tsUndefinedKeyword
t.tsUndefinedKeyword();
另请参阅 t.isTSUndefinedKeyword(node, opts) 和 t.assertTSUndefinedKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsUnionType
t.tsUnionType(types);
另请参阅 t.isTSUnionType(node, opts) 和 t.assertTSUnionType(node, opts)。
AST 节点 TSUnionType 的结构:
types:TSType[](必需)
别名:TypeScript, TSType
tsUnknownKeyword
t.tsUnknownKeyword();
另请参阅 t.isTSUnknownKeyword(node, opts) 和 t.assertTSUnknownKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
tsVoidKeyword
t.tsVoidKeyword();
另请参阅 t.isTSVoidKeyword(node, opts) 和 t.assertTSVoidKeyword(node, opts)。
别名:TypeScript, TSType, TSBaseType
标签模板表达式
t.taggedTemplateExpression(tag, quasi);
另请参阅 t.isTaggedTemplateExpression(node, opts) 和 t.assertTaggedTemplateExpression(node, opts)。
AST 节点 TaggedTemplateExpression 的结构:
-
tag:Expression(必需) -
quasi:TemplateLiteral(必需) -
typeParameters:TypeParameterInstantiation | TSTypeParameterInstantiation(默认值:null, 不包含在构造器函数中)
模板元素
t.templateElement(value, tail);
另请参阅 t.isTemplateElement(node, opts) 和 t.assertTemplateElement(node, opts)。
AST 节点 TemplateElement 的结构:
-
value:{ raw: string, cooked?: string }(必需) -
tail:boolean(默认值:false)
别名: Standardized
模板字面量
t.templateLiteral(quasis, expressions);
另请参阅 t.isTemplateLiteral(node, opts) 和 t.assertTemplateLiteral(node, opts)。
AST 节点 TemplateLiteral 的结构:
-
quasis:TemplateElement[](必需) -
expressions:(Expression | TSType)[](必需)
别名:Standardized, Expression, Literal
this 表达式
t.thisExpression();
另请参阅 t.isThisExpression(node, opts) 和 t.assertThisExpression(node, opts)。
this 类型注解
t.thisTypeAnnotation();
另请参阅 t.isThisTypeAnnotation(node, opts) 和 t.assertThisTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
throw 语句
t.throwStatement(argument);
另请参阅 t.isThrowStatement(node, opts) 和 t.assertThrowStatement(node, opts)。
AST 节点 ThrowStatement 的结构:
argument:Expression(必填)
别名:Standardized, Statement, Terminatorless, CompletionStatement
主题引用
t.topicReference();
另请参阅 t.isTopicReference(node, opts) 和 t.assertTopicReference(node, opts)。
别名:Expression
try 语句
t.tryStatement(block, handler, finalizer);
另请参阅 t.isTryStatement(node, opts) 和 t.assertTryStatement(node, opts)。
AST 节点 TryStatement 的结构:
-
block:BlockStatement(必需) -
handler:CatchClause(默认值:null) -
finalizer:BlockStatement(默认值:null)
别名: Standardized, Statement
元组表达式
t.tupleExpression(elements);
另见 t.isTupleExpression(node, opts) 和 t.assertTupleExpression(node, opts)。
AST 节点 TupleExpression 的结构:
elements:(Expression | SpreadElement)[](默认值:[])
别名:Expression
tupleTypeAnnotation
t.tupleTypeAnnotation(types);
另见 t.isTupleTypeAnnotation(node, opts) 和 t.assertTupleTypeAnnotation(node, opts)。
AST 节点 TupleTypeAnnotation 的结构:
types:FlowType[](必需)
typeAlias
t.typeAlias(id, typeParameters, right);
另见 t.isTypeAlias(node, opts) 和 t.assertTypeAlias(node, opts)。
AST 节点 TypeAlias 的结构:
-
id:Identifier(必需) -
typeParameters:TypeParameterDeclaration(默认值:null) -
right:FlowType(必需)
别名:Flow, FlowDeclaration, Statement, Declaration
typeAnnotation
t.typeAnnotation(typeAnnotation);
另见 t.isTypeAnnotation(node, opts) 和 t.assertTypeAnnotation(node, opts)。
AST 节点 TypeAnnotation 的结构:
typeAnnotation:FlowType(必需)
别名: Flow
typeCastExpression
t.typeCastExpression(expression, typeAnnotation);
另见 t.isTypeCastExpression(node, opts) 和 t.assertTypeCastExpression(node, opts)。
AST 节点 TypeCastExpression 的结构:
-
expression:Expression(必需) -
typeAnnotation:TypeAnnotation(必需)
别名:Flow, ExpressionWrapper, Expression
typeParameter
t.typeParameter(bound, default, variance);
另见 t.isTypeParameter(node, opts) 和 t.assertTypeParameter(node, opts)。
AST 节点 TypeParameter 的结构:
-
bound:TypeAnnotation(默认值:null) -
default:FlowType(默认值:null) -
variance:Variance(默认值:null) -
name:string(必填)
别名: Flow
typeParameterDeclaration
t.typeParameterDeclaration(params);
另见 t.isTypeParameterDeclaration(node, opts) 和 t.assertTypeParameterDeclaration(node, opts)。
AST 节点 TypeParameterDeclaration 的结构:
params:TypeParameter[](必需)
别名: Flow
typeParameterInstantiation
t.typeParameterInstantiation(params);
另见 t.isTypeParameterInstantiation(node, opts) 和 t.assertTypeParameterInstantiation(node, opts)。
AST 节点 TypeParameterInstantiation 的结构:
params:FlowType[](必需)
别名: Flow
typeofTypeAnnotation
t.typeofTypeAnnotation(argument);
另见 t.isTypeofTypeAnnotation(node, opts) 和 t.assertTypeofTypeAnnotation(node, opts)。
AST 节点 TypeofTypeAnnotation 结构:
argument:FlowType(必填)
unaryExpression
t.unaryExpression(operator, argument, prefix);
另见 t.isUnaryExpression(node, opts) 和 t.assertUnaryExpression(node, opts)。
AST 节点 UnaryExpression 结构:
-
operator:"void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof"(必填) -
argument:Expression(必填) -
prefix:boolean(默认:true)
别名:Standardized, UnaryLike, Expression
unionTypeAnnotation
t.unionTypeAnnotation(types);
另见 t.isUnionTypeAnnotation(node, opts) 和 t.assertUnionTypeAnnotation(node, opts)。
AST 节点 UnionTypeAnnotation 结构:
types:FlowType[](必需)
updateExpression
t.updateExpression(operator, argument, prefix);
另见 t.isUpdateExpression(node, opts) 和 t.assertUpdateExpression(node, opts)。
AST 节点 UpdateExpression 结构:
-
operator:"++" | "--"(必填) -
argument:Expression(必填) -
prefix:boolean(默认:false)
v8IntrinsicIdentifier
t.v8IntrinsicIdentifier(name);
另见 t.isV8IntrinsicIdentifier(node, opts) 和 t.assertV8IntrinsicIdentifier(node, opts)。
AST 节点 V8IntrinsicIdentifier 结构:
name:string(必填)
variableDeclaration
t.variableDeclaration(kind, declarations);
History
| Version | Changes |
|---|---|
v7.20.0 | kind can be "using". |
v7.22.0 | kind can be "await using". |
另见 t.isVariableDeclaration(node, opts) 和 t.assertVariableDeclaration(node, opts)。
AST 节点 VariableDeclaration 结构:
-
kind:"var" | "let" | "const" | "using" | "await using"(必填) -
declarations:VariableDeclarator[](必需) -
declare:boolean(默认:null, 构建函数中排除)
别名:Standardized, Statement, Declaration
variableDeclarator
t.variableDeclarator(id, init);
另见 t.isVariableDeclarator(node, opts) 和 t.assertVariableDeclarator(node, opts)。
AST 节点 VariableDeclarator 结构:
-
id:LVal | VoidPattern(必填) -
init:Expression(默认值:null) -
definite:boolean(默认值:null,构建函数中不包含此参数)
别名: Standardized
variance
t.variance(kind);
另请参阅 t.isVariance(node, opts) 和 t.assertVariance(node, opts)。
AST 节点 Variance 的结构:
kind:"minus" | "plus"(必需)
别名: Flow
voidPattern
t.voidPattern();
History
| Version | Changes |
|---|---|
v7.28.0 | Introduced |
另请参阅 t.isVoidPattern(node, opts) 和 t.assertVoidPattern(node, opts)。
别名: Pattern, PatternLike, FunctionParameter
voidTypeAnnotation
t.voidTypeAnnotation();
另请参阅 t.isVoidTypeAnnotation(node, opts) 和 t.assertVoidTypeAnnotation(node, opts)。
别名: Flow, FlowType, FlowBaseAnnotation
whileStatement
t.whileStatement(test, body);
另请参阅 t.isWhileStatement(node, opts) 和 t.assertWhileStatement(node, opts)。
AST 节点 WhileStatement 的结构:
-
test:Expression(必需) -
body:Statement(必需)
别名: Standardized, Statement, BlockParent, Loop, While, Scopable
withStatement
t.withStatement(object, body);
另请参阅 t.isWithStatement(node, opts) 和 t.assertWithStatement(node, opts)。
AST 节点 WithStatement 的结构:
-
object:Expression(必需) -
body:Statement(必需)
别名: Standardized, Statement
yieldExpression
t.yieldExpression(argument, delegate);
另请参阅 t.isYieldExpression(node, opts) 和 t.assertYieldExpression(node, opts)。
AST 节点 YieldExpression 的结构:
-
argument:Expression(默认值:null) -
delegate:boolean(默认值:false)
别名: Standardized, Expression, Terminatorless
别名
Accessor
已弃用。将在 Babel 8 中移除。
t.isAccessor(node);
涵盖节点:
ClassAccessorProperty(类访问器属性)
Binary
涵盖 BinaryExpression 和 LogicalExpression 的统称,二者共享相同的 AST 结构。
t.isBinary(node);
涵盖节点:
-
LogicalExpression(逻辑表达式)
Block
已弃用。将在 Babel 8 中移除。
t.isBlock(node);
涵盖节点:
BlockParent
涵盖了一组 AST 节点,这些节点会创建带有新 LexicalEnvironment 的执行上下文。换句话说,它们定义了 let 和 const 声明的作用域。
t.isBlockParent(node);
涵盖节点:
-
CatchClause(catch子句) -
ClassMethod(类方法) -
ClassPrivateMethod(类私有方法) -
FunctionExpression(函数表达式) -
Program(程序)
Class
涵盖 ClassExpression 和 ClassDeclaration 节点,它们共享相同的 AST 结构。
t.isClass(node);
涵盖节点:
-
ClassExpression(类表达式)
CompletionStatement
表示完成记录的语句。它们定义了程序的控制流,例如循环何时中断或操作何时抛出严重错误。
t.isCompletionStatement(node);
涵盖节点:
Conditional
涵盖 ConditionalExpression 和 IfStatement 节点,它们共享相同的 AST 结构。
t.isConditional(node);
涵盖节点:
-
ConditionalExpression(条件表达式)
Declaration
涵盖所有声明节点。
t.isDeclaration(node);
涵盖节点:
EnumBody
Flow 枚举体的分组类别。
t.isEnumBody(node);
涵盖节点:
EnumMember
Flow 枚举成员的分组类别。
t.isEnumMember(node);
涵盖节点:
ExportDeclaration
所有 ExportDeclaration 的分组类别。
t.isExportDeclaration(node);
涵盖节点:
Expression
所有 Expression 的分组类别。
t.isExpression(node);
涵盖节点:
-
ClassExpression(类表达式) -
ConditionalExpression(条件表达式) -
FunctionExpression(函数表达式) -
Import(import表达式) -
ImportExpression(动态导入表达式) -
LogicalExpression(逻辑表达式) -
MemberExpression(成员表达式) -
MetaProperty(元属性) -
NullLiteral(null字面量) -
NumericLiteral(数字字面量) -
ObjectExpression(对象表达式) -
OptionalCallExpression(可选调用表达式) -
OptionalMemberExpression(可选成员表达式) -
ParenthesizedExpression(括号表达式) -
RegExpLiteral(正则表达式字面量)
ExpressionWrapper
一种没有运行时语义的表达式包装器。
t.isExpressionWrapper(node);
涵盖节点:
Flow
Flow 类型系统定义的 AST 节点集合。
t.isFlow(node);
涵盖节点:
FlowBaseAnnotation
基础 Flow 类型注解的集合。
t.isFlowBaseAnnotation(node);
涵盖节点:
FlowDeclaration
Flow 声明的集合。
t.isFlowDeclaration(node);
涵盖节点:
FlowPredicate
Flow 断言的集合。
t.isFlowPredicate(node);
涵盖节点:
FlowType
Flow 类型注解的集合。
t.isFlowType(node);
涵盖节点:
For
涵盖 ForStatement 和 ForXStatement 的类别。
t.isFor(node);
涵盖节点:
ForXStatement
涵盖 ForIn 和 ForOf 语句的类别。
t.isForXStatement(node);
涵盖节点:
Function
涵盖函数和方法的类别,必须包含 body 和 params。注意:Function 与 FunctionParent 不同。例如,StaticBlock 属于 FunctionParent 但不属于 Function。
t.isFunction(node);
涵盖节点:
-
ClassMethod(类方法) -
ClassPrivateMethod(类私有方法) -
FunctionExpression(函数表达式)
FunctionParameter
涵盖函数参数的类别。它们是形参列表的组成部分。
t.isFunctionParameter(node);
涵盖节点:
FunctionParent
覆盖了通过新建 VariableEnvironment 启动执行上下文的 AST 节点。这些节点定义了 var 声明的范围。从 Babel 7 开始,FunctionParent 不再包含 Program 节点。
t.isFunctionParent(node);
涵盖节点:
-
ClassMethod(类方法) -
ClassPrivateMethod(类私有方法) -
FunctionExpression(函数表达式)
不可变
覆盖不可变对象和 JSX 元素。当对象创建后无法再定义其他属性时,该对象即为不可变对象。
t.isImmutable(node);
涵盖节点:
-
NullLiteral(null字面量) -
NumericLiteral(数字字面量)
导入或导出声明
History
| Version | Changes |
|---|---|
v7.21.0 | Introduced |
覆盖 ImportDeclaration 和 ExportDeclaration。
t.isImportOrExportDeclaration(node);
涵盖节点:
JSX
覆盖为 JSX 定义的 AST 节点。
t.isJSX(node);
涵盖节点:
LVal
涵盖用于赋值表达式 left 以及 ForXStatement 中的左侧表达式。
t.isLVal(node);
涵盖节点:
-
MemberExpression(成员表达式) -
ObjectPattern(对象模式)
Literal
涵盖 Literal、Regular Expression Literal 和 Template Literal。
t.isLiteral(node);
涵盖节点:
-
NullLiteral(null字面量) -
NumericLiteral(数字字面量) -
RegExpLiteral(正则表达式字面量)
Loop
涵盖循环语句。
t.isLoop(node);
涵盖节点:
Method
涵盖对象方法和类方法。
t.isMethod(node);
涵盖节点:
-
ClassMethod(类方法) -
ClassPrivateMethod(类私有方法)
杂项
涵盖对开发有时有用的非标准 AST 类型。
t.isMiscellaneous(node);
涵盖节点:
ModuleDeclaration
History
| Version | Changes |
|---|---|
v7.21.0 | Deprecated |
已弃用,请改用 ImportOrExportDeclaration。迁移说明请参见 PR #15266。
t.isModuleDeclaration(node);
涵盖节点:
ModuleSpecifier
涵盖导入/导出说明符的节点类别。注意:它_并非_规范中定义的 ModuleSpecifier。
t.isModuleSpecifier(node);
涵盖节点:
-
ExportNamespaceSpecifier(导出命名空间说明符) -
ExportSpecifier(导出说明符) -
ImportDefaultSpecifier(导入默认说明符) -
ImportNamespaceSpecifier(导入命名空间说明符) -
ImportSpecifier(导入说明符)
ObjectMember
涵盖对象字面量中的成员。
t.isObjectMember(node);
涵盖节点:
Pattern
涵盖除 Identifier 外的所有绑定模式。
t.isPattern(node);
涵盖节点:
PatternLike
涵盖所有绑定模式。
t.isPatternLike(node);
涵盖节点:
-
MemberExpression(成员表达式) -
ObjectPattern(对象模式)
Private
涵盖私有类元素和私有标识符。
t.isPrivate(node);
涵盖节点:
-
ClassPrivateMethod(类私有方法) -
ClassPrivateProperty(类私有属性) -
PrivateName(私有名称)
Property
涵盖对象属性和类属性。
t.isProperty(node);
涵盖节点:
-
ClassAccessorProperty(类访问器属性) -
ClassPrivateProperty(类私有属性) -
ClassProperty(类属性)
纯类节点
指没有副作用的 AST 节点。换句话说,即使多次求值也不会产生可观测的行为变化。
t.isPureish(node);
涵盖节点:
-
FunctionExpression(函数表达式) -
NullLiteral(null字面量) -
NumericLiteral(数字字面量) -
RegExpLiteral(正则表达式字面量)
作用域节点
覆盖了 FunctionParent 和 BlockParent 类型的节点。
t.isScopable(node);
涵盖节点:
-
CatchClause(catch子句) -
ClassExpression(类表达式) -
ClassMethod(类方法) -
ClassPrivateMethod(类私有方法) -
FunctionExpression(函数表达式) -
Program(程序)
标准节点
指符合 ECMAScript 官方规范的 AST 节点。
t.isStandardized(node);
涵盖节点:
-
CatchClause(catch子句) -
ClassAccessorProperty(类访问器属性) -
ClassBody(类体) -
ClassExpression(类表达式) -
ClassMethod(类方法) -
ClassPrivateMethod(类私有方法) -
ClassPrivateProperty(类私有属性) -
ClassProperty(类属性) -
ConditionalExpression(条件表达式) -
Directive(指令) -
DirectiveLiteral(指令字面量) -
EmptyStatement(空语句) -
ExportNamespaceSpecifier(导出命名空间说明符) -
ExportSpecifier(导出说明符) -
File(文件) -
FunctionExpression(函数表达式) -
Import(import表达式) -
ImportAttribute(导入属性) -
ImportDefaultSpecifier(导入默认说明符) -
ImportExpression(动态导入表达式) -
ImportNamespaceSpecifier(导入命名空间说明符) -
ImportSpecifier(导入说明符) -
InterpreterDirective(解释器指令) -
LogicalExpression(逻辑表达式) -
MemberExpression(成员表达式) -
MetaProperty(元属性) -
NullLiteral(null字面量) -
NumericLiteral(数字字面量) -
ObjectExpression(对象表达式) -
ObjectPattern(对象模式) -
OptionalCallExpression(可选调用表达式) -
OptionalMemberExpression(可选成员表达式) -
ParenthesizedExpression(括号表达式) -
PrivateName(私有名称) -
Program(程序) -
RegExpLiteral(正则表达式字面量) -
WithStatement(with语句)
语句
本节涵盖所有语句节点。
t.isStatement(node);
涵盖节点:
-
EmptyStatement(空语句) -
WithStatement(with语句)
TSBaseType
对主要 TypeScript 类型注解的覆盖。
t.isTSBaseType(node);
涵盖节点:
TSEntityName
对 TypeScript 实体的覆盖。
t.isTSEntityName(node);
涵盖节点:
TSType
对 TypeScript 类型注解的覆盖。
t.isTSType(node);
涵盖节点:
TSTypeElement
TypeScript 类型声明的集合。
t.isTSTypeElement(node);
涵盖节点:
Terminatorless
当操作符与操作数间插入行终止符时会改变语义的 AST 节点集合。
t.isTerminatorless(node);
涵盖节点:
TypeScript
TypeScript 专属 AST 节点的集合。
t.isTypeScript(node);
涵盖节点:
一元操作类
涵盖 UnaryExpression 和 SpreadElement 的类别。
t.isUnaryLike(node);
涵盖节点:
用户可空白节点(已弃用)
已弃用。将在 Babel 8 中移除。
t.isUserWhitespacable(node);
涵盖节点:
While 循环节点
涵盖 DoWhileStatement 和 WhileStatement 的类别,它们共享相同的 AST 结构。
t.isWhile(node);
涵盖节点: