@babel/types
此模块包含用于手动构建 AST 以及检查 AST 节点类型的方法。
安装
- npm
- Yarn
- pnpm
npm install --save-dev @babel/types
yarn add --dev @babel/types
pnpm add --save-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:Array<null | Expression | SpreadElement>(默认值:[])
arrayPattern
t.arrayPattern(elements);
另请参阅 t.isArrayPattern(node, opts) 和 t.assertArrayPattern(node, opts)。
AST 节点 ArrayPattern 形状
elements:Array<null | PatternLike | LVal>(必需)decorators:Array<Decorator>(默认值:null,从构建器函数中排除)optional:boolean(默认值:null,从构建器函数中排除)typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,从构建器函数中排除)
别名:Standardized、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:Array<Identifier | Pattern | RestElement>(必需)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:Array<Decorator>(默认值:null,从构建器函数中排除)optional:boolean(默认值:null,从构建器函数中排除)typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,从构建器函数中排除)
别名:Standardized、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(必需)
别名: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
blockStatement
t.blockStatement(body, directives);
另请参阅 t.isBlockStatement(node, opts) 和 t.assertBlockStatement(node, opts)。
AST 节点 BlockStatement 形状
body:Array<Statement>(必需)directives:Array<Directive>(默认值:[])
别名:Standardized、Scopable、BlockParent、Block、Statement
booleanLiteral
t.booleanLiteral(value);
另请参阅 t.isBooleanLiteral(node, opts) 和 t.assertBooleanLiteral(node, opts)。
AST 节点 BooleanLiteral 形状
value:boolean(必需)
别名:Standardized、Expression、Pureish、Literal、Immutable
booleanLiteralTypeAnnotation
t.booleanLiteralTypeAnnotation(value);
另请参阅 t.isBooleanLiteralTypeAnnotation(node, opts) 和 t.assertBooleanLiteralTypeAnnotation(node, opts)。
AST 节点 BooleanLiteralTypeAnnotation 形状
value:boolean(必需)
booleanTypeAnnotation
t.booleanTypeAnnotation();
另请参阅 t.isBooleanTypeAnnotation(node, opts) 和 t.assertBooleanTypeAnnotation(node, opts)。
别名:Flow、FlowType、FlowBaseAnnotation
breakStatement
t.breakStatement(label);
另请参阅 t.isBreakStatement(node, opts) 和 t.assertBreakStatement(node, opts)。
AST 节点 BreakStatement 形状
label:Identifier(默认值:null)
别名:Standardized、Statement、Terminatorless、CompletionStatement
callExpression
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(默认值:null,从生成器函数中排除)typeArguments:TypeParameterInstantiation(默认值:null,从生成器函数中排除)typeParameters:TSTypeParameterInstantiation(默认值:null,从生成器函数中排除)
catchClause
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:Array<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:Array<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:Array<Decorator>(默认值:null)abstract:boolean(默认值:null,从构建器函数中排除)declare:boolean(默认值:null,从构建器函数中排除)implements:Array<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:Array<Decorator>(默认值:null)implements:Array<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:Array<Identifier | Pattern | RestElement | 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:Array<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:Array<Identifier | Pattern | RestElement | 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:Array<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:Array<Decorator>(默认值:null)static:boolean(默认值:false)definite:boolean(默认值:null,从构建器函数中排除)readonly:boolean(默认值:null,从构建器函数中排除)typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,从构建器函数中排除)variance:Variance(默认值:null,从构建器函数中排除)
别名:Standardized、Property、Private
classProperty
t.classProperty(key, value, typeAnnotation, decorators, computed, static);
历史记录
| 版本 | 更改 |
|---|---|
v7.6.0 | 支持 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:Array<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,从构建器函数中排除)
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)。
decimalLiteral
t.decimalLiteral(value);
另请参阅 t.isDecimalLiteral(node, opts) 和 t.assertDecimalLiteral(node, opts)。
AST 节点 DecimalLiteral 形状
value:string(必需)
别名: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:Array<InterfaceExtends>(默认:null)body:ObjectTypeAnnotation(必需)implements:Array<ClassImplements>(默认值:null,从构建器函数中排除)mixins:Array<InterfaceExtends>(默认值:null,从构建器函数中排除)
别名:Flow、FlowDeclaration、Statement、Declaration
declareExportAllDeclaration
t.declareExportAllDeclaration(source);
另请参阅 t.isDeclareExportAllDeclaration(node, opts) 和 t.assertDeclareExportAllDeclaration(node, opts)。
AST 节点 DeclareExportAllDeclaration 形状
source:StringLiteral(必需)exportKind:"type" | "value"(默认值:null,从构建器函数中排除)
别名:Flow、FlowDeclaration、Statement、Declaration
declareExportDeclaration
t.declareExportDeclaration(declaration, specifiers, source);
另请参阅 t.isDeclareExportDeclaration(node, opts) 和 t.assertDeclareExportDeclaration(node, opts)。
AST 节点 DeclareExportDeclaration 形状
declaration:Flow(默认值:null)specifiers:Array<ExportSpecifier | ExportNamespaceSpecifier>(默认值:null)source:StringLiteral(默认值: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:Array<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(必需)
装饰器
t.decorator(expression);
另请参见 t.isDecorator(node, opts) 和 t.assertDecorator(node, opts)。
AST 节点 Decorator 形状
expression:Expression(必需)
指令
t.directive(value);
另请参见 t.isDirective(node, opts) 和 t.assertDirective(node, opts)。
AST 节点 Directive 形状
value:DirectiveLiteral(必需)
别名:Standardized
指令文本
t.directiveLiteral(value);
另请参见 t.isDirectiveLiteral(node, opts) 和 t.assertDirectiveLiteral(node, opts)。
AST 节点 DirectiveLiteral 形状
value:string(必需)
别名:Standardized
do 表达式
t.doExpression(body, async);
另请参见 t.isDoExpression(node, opts) 和 t.assertDoExpression(node, opts)。
AST 节点 DoExpression 形状
body:BlockStatement(必需)async:boolean(默认:false)
别名:Expression
do while 语句
t.doWhileStatement(test, body);
另请参见 t.isDoWhileStatement(node, opts) 和 t.assertDoWhileStatement(node, opts)。
AST 节点 DoWhileStatement 形状
test:Expression(必需)body:Statement(必需)
别名:Standardized、Statement、BlockParent、Loop、While、Scopable
空语句
t.emptyStatement();
另请参见 t.isEmptyStatement(node, opts) 和 t.assertEmptyStatement(node, opts)。
空类型注释
t.emptyTypeAnnotation();
另请参见 t.isEmptyTypeAnnotation(node, opts) 和 t.assertEmptyTypeAnnotation(node, opts)。
别名:Flow、FlowType、FlowBaseAnnotation
枚举布尔正文
t.enumBooleanBody(members);
另请参见 t.isEnumBooleanBody(node, opts) 和 t.assertEnumBooleanBody(node, opts)。
AST 节点 EnumBooleanBody 形状
members:Array<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(必需)
枚举默认成员
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:Array<EnumNumberMember>(必需)explicitType:boolean(必需)hasUnknownMembers:boolean(必需)
enumNumberMember
t.enumNumberMember(id, init);
另请参阅 t.isEnumNumberMember(node, opts) 和 t.assertEnumNumberMember(node, opts)。
AST 节点 EnumNumberMember 形状
id:Identifier(必需)init:NumericLiteral(必需)
别名:Flow、EnumMember
enumStringBody
t.enumStringBody(members);
另请参阅 t.isEnumStringBody(node, opts) 和 t.assertEnumStringBody(node, opts)。
AST 节点 EnumStringBody 形状
members:Array<EnumStringMember | EnumDefaultedMember>(必需)explicitType:boolean(必需)hasUnknownMembers:boolean(必需)
enumStringMember
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:Array<EnumDefaultedMember>(必需)hasUnknownMembers:boolean(必需)
existsTypeAnnotation
t.existsTypeAnnotation();
另请参阅 t.isExistsTypeAnnotation(node, opts) 和 t.assertExistsTypeAnnotation(node, opts)。
exportAllDeclaration
t.exportAllDeclaration(source);
另请参阅 t.isExportAllDeclaration(node, opts) 和 t.assertExportAllDeclaration(node, opts)。
AST 节点 ExportAllDeclaration 形状
source:StringLiteral(必需)assertions:Array<ImportAttribute>(默认值:null,从构建器函数中排除)attributes:Array<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);
另请参阅 t.isExportNamedDeclaration(node, opts) 和 t.assertExportNamedDeclaration(node, opts)。
AST 节点 ExportNamedDeclaration 形状
declaration:Declaration(默认值:null)specifiers:Array<ExportSpecifier | ExportDefaultSpecifier | ExportNamespaceSpecifier>(默认值:[])source:StringLiteral(默认值:null)assertions:Array<ImportAttribute>(默认值:null,从构建器函数中排除)attributes:Array<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:标识符 | 字符串字面量(必需)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:Array<CommentBlock | CommentLine>(默认值:null)tokens:Array<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:Array<Identifier | Pattern | RestElement>(必需)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:Array<Identifier | Pattern | RestElement>(必需)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:Array<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:Array<Decorator>(默认值:null,从构建器函数中排除)optional:boolean(默认值:null,从构建器函数中排除)typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,从构建器函数中排除)
别名:Standardized、Expression、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(必需)
importDeclaration
t.importDeclaration(specifiers, source);
历史记录
| 版本 | 更改 |
|---|---|
v7.20.0 | 支持 module |
另请参阅 t.isImportDeclaration(node, opts) 和 t.assertImportDeclaration(node, opts)。
AST 节点 ImportDeclaration 形状
specifiers:Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>(必需)source:StringLiteral(必需)assertions:Array<ImportAttribute>(默认值:null,从构建器函数中排除)attributes:Array<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)。
interfaceDeclaration
t.interfaceDeclaration(id, typeParameters, extends, body);
另请参见 t.isInterfaceDeclaration(node, opts) 和 t.assertInterfaceDeclaration(node, opts)。
AST 节点 InterfaceDeclaration 形状
id:Identifier(必需)typeParameters:TypeParameterDeclaration(默认:null)extends:Array<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:Array<InterfaceExtends>(默认:null)body:ObjectTypeAnnotation(必需)
interpreterDirective
t.interpreterDirective(value);
另请参见 t.isInterpreterDirective(node, opts) 和 t.assertInterpreterDirective(node, opts)。
AST 节点 InterpreterDirective 形状
value:string(必需)
别名:Standardized
intersectionTypeAnnotation
t.intersectionTypeAnnotation(types);
另请参见 t.isIntersectionTypeAnnotation(node, opts) 和 t.assertIntersectionTypeAnnotation(node, opts)。
AST 节点 IntersectionTypeAnnotation 形状
types:Array<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:Array<JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment>(必需)selfClosing:boolean(默认值:null)
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:Array<JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment>(必需)
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:Array<JSXAttribute | JSXSpreadAttribute>(必需)selfClosing:boolean(默认值:false)typeParameters:TypeParameterInstantiation | 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(必需)
labeledStatement
t.labeledStatement(label, body);
另请参阅 t.isLabeledStatement(node, opts) 和 t.assertLabeledStatement(node, opts)。
AST 节点 LabeledStatement 形状
label:Identifier(必需)body:Statement(必需)
逻辑表达式
t.logicalExpression(operator, left, right);
另请参阅 t.isLogicalExpression(node, opts) 和 t.assertLogicalExpression(node, opts)。
AST 节点 LogicalExpression 形状
operator:"||" | "&&" | "??"(必需)left:Expression(必需)right:Expression(必需)
别名:Standardized、Binary、Expression
成员表达式
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:true | false(默认值:null)
别名:Standardized、Expression、LVal
元属性
t.metaProperty(meta, property);
另请参阅 t.isMetaProperty(node, opts) 和 t.assertMetaProperty(node, opts)。
AST 节点 MetaProperty 形状
meta:Identifier(必需)property:Identifier(必需)
混合类型注解
t.mixedTypeAnnotation();
另请参阅 t.isMixedTypeAnnotation(node, opts) 和 t.assertMixedTypeAnnotation(node, opts)。
别名:Flow、FlowType、FlowBaseAnnotation
模块表达式
t.moduleExpression(body);
另请参阅 t.isModuleExpression(node, opts) 和 t.assertModuleExpression(node, opts)。
AST 节点 ModuleExpression 形状
body:Program(必需)
别名:Expression
新表达式
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(默认值:null,从生成器函数中排除)typeArguments:TypeParameterInstantiation(默认值:null,从生成器函数中排除)typeParameters:TSTypeParameterInstantiation(默认值:null,从生成器函数中排除)
空操作
t.noop();
另请参阅 t.isNoop(node, opts) 和 t.assertNoop(node, opts)。
空文字
t.nullLiteral();
另请参阅 t.isNullLiteral(node, opts) 和 t.assertNullLiteral(node, opts)。
别名:Standardized、Expression、Pureish、Literal、Immutable
空文字类型注解
t.nullLiteralTypeAnnotation();
另请参阅 t.isNullLiteralTypeAnnotation(node, opts) 和 t.assertNullLiteralTypeAnnotation(node, opts)。
别名:Flow、FlowType、FlowBaseAnnotation
可空类型注解
t.nullableTypeAnnotation(typeAnnotation);
另请参阅 t.isNullableTypeAnnotation(node, opts) 和 t.assertNullableTypeAnnotation(node, opts)。
AST 节点 NullableTypeAnnotation 形状
typeAnnotation:FlowType(必需)
数字文字类型注解
t.numberLiteralTypeAnnotation(value);
另请参阅 t.isNumberLiteralTypeAnnotation(node, opts) 和 t.assertNumberLiteralTypeAnnotation(node, opts)。
AST 节点 NumberLiteralTypeAnnotation 形状
value:number(必需)
数字类型注解
t.numberTypeAnnotation();
另请参阅 t.isNumberTypeAnnotation(node, opts) 和 t.assertNumberTypeAnnotation(node, opts)。
别名:Flow、FlowType、FlowBaseAnnotation
数字文字
t.numericLiteral(value);
另请参阅t.isNumericLiteral(node, opts)和t.assertNumericLiteral(node, opts)。
AST 节点NumericLiteral形状
value:非负有限number(必需)
别名:Standardized、Expression、Pureish、Literal、Immutable
对象表达式
t.objectExpression(properties);
另请参阅t.isObjectExpression(node, opts)和t.assertObjectExpression(node, opts)。
AST 节点ObjectExpression形状
properties:Array<ObjectMethod | ObjectProperty | SpreadElement>(必需)
对象方法
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:Array<Identifier | Pattern | RestElement>(必需)body:BlockStatement(必需)computed:boolean(默认值:false)generator:boolean(默认值:false)async:boolean(默认:false)decorators:Array<Decorator>(默认值:null,从构建器函数中排除)returnType:TypeAnnotation | TSTypeAnnotation | Noop(默认:null,从构建器函数中排除)typeParameters:TypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认:null,从构建器函数中排除)
别名:Standardized、UserWhitespacable、Function、Scopable、BlockParent、FunctionParent、Method、ObjectMember
对象模式
t.objectPattern(properties);
另请参阅t.isObjectPattern(node, opts)和t.assertObjectPattern(node, opts)。
AST 节点ObjectPattern形状
properties:Array<RestElement | ObjectProperty>(必需)decorators:Array<Decorator>(默认值:null,从构建器函数中排除)optional:boolean(默认值:null,从构建器函数中排除)typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,从构建器函数中排除)
别名:Standardized、Pattern、PatternLike、LVal
对象属性
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:Array<Decorator>(默认值:null)
别名:Standardized、UserWhitespacable、Property、ObjectMember
对象类型注释
t.objectTypeAnnotation(properties, indexers, callProperties, internalSlots, exact);
另请参阅t.isObjectTypeAnnotation(node, opts)和t.assertObjectTypeAnnotation(node, opts)。
AST 节点ObjectTypeAnnotation形状
properties:Array<ObjectTypeProperty | ObjectTypeSpreadProperty>(必需)indexers:Array<ObjectTypeIndexer>(默认:[])callProperties:Array<ObjectTypeCallProperty>(默认:[])internalSlots:Array<ObjectTypeInternalSlot>(默认:[])exact:boolean(默认:false)inexact:boolean(默认:null,从生成器函数中排除)
对象类型调用属性
t.objectTypeCallProperty(value);
另请参阅t.isObjectTypeCallProperty(node, opts)和t.assertObjectTypeCallProperty(node, opts)。
AST 节点ObjectTypeCallProperty形状
value:FlowType(必需)static:boolean(必需)
对象类型索引器
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(必需)
对象类型内部槽
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:Array<Expression | SpreadElement | JSXNamespacedName | 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:"标识符" | "字符串字面量" | "表达式" | "语句" | "声明" | "块语句" | "类主体" | "模式"(必需)name:标识符(必需)
privateName
t.privateName(id);
另请参阅 t.isPrivateName(node, opts) 和 t.assertPrivateName(node, opts)。
AST 节点 PrivateName 形状
id:Identifier(必需)
program
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(默认:null)
别名:Standardized,Scopable,BlockParent,Block
qualifiedTypeIdentifier
t.qualifiedTypeIdentifier(id, qualification);
另请参阅 t.isQualifiedTypeIdentifier(node, opts) 和 t.assertQualifiedTypeIdentifier(node, opts)。
AST 节点 QualifiedTypeIdentifier 形状
id:Identifier(必需)qualification:标识符 | QualifiedTypeIdentifier(必需)
别名:Flow
recordExpression
t.recordExpression(properties);
另请参阅 t.isRecordExpression(node, opts) 和 t.assertRecordExpression(node, opts)。
AST 节点 RecordExpression 形状
properties:Array<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:LVal(必需)decorators:Array<Decorator>(默认值:null,从构建器函数中排除)optional:boolean(默认值:null,从构建器函数中排除)typeAnnotation:TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,从构建器函数中排除)
别名:Standardized,LVal,PatternLike
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:Array<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:Array<Statement>(必需)
别名:Standardized、Scopable、BlockParent、FunctionParent
stringLiteral
t.stringLiteral(value);
另请参阅 t.isStringLiteral(node, opts) 和 t.assertStringLiteral(node, opts)。
AST 节点 StringLiteral 形状
value:string(必需)
别名:Standardized、Expression、Pureish、Literal、Immutable
stringLiteralTypeAnnotation
t.stringLiteralTypeAnnotation(value);
另请参阅 t.isStringLiteralTypeAnnotation(node, opts) 和 t.assertStringLiteralTypeAnnotation(node, opts)。
AST 节点 StringLiteralTypeAnnotation 形状
value:string(必需)
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:Array<Statement>(必需)
别名:Standardized
switchStatement
t.switchStatement(discriminant, cases);
另请参阅 t.isSwitchStatement(node, opts) 和 t.assertSwitchStatement(node, opts)。
AST 节点 SwitchStatement 形状
discriminant:Expression(必需)cases:Array<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:Array<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:Array<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:Array<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:Array<Identifier | Pattern | RestElement>(必需)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:Array<Decorator>(默认值:null)key:Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression(必需)typeParameters:TSTypeParameterDeclaration | Noop(默认值:null)params:Array<Identifier | Pattern | RestElement | 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
tsEnumDeclaration
t.tsEnumDeclaration(id, members);
另请参见 t.isTSEnumDeclaration(node, opts) 和 t.assertTSEnumDeclaration(node, opts)。
AST 节点 TSEnumDeclaration 形状
id:Identifier(必需)members:Array<TSEnumMember>(必需)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:Array<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(必需)
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:Expression(默认值:null,从构建器函数中排除)
别名:TypeScript、TSType
tsIndexSignature
t.tsIndexSignature(parameters, typeAnnotation);
另请参阅 t.isTSIndexSignature(node, opts) 和 t.assertTSIndexSignature(node, opts)。
AST 节点 TSIndexSignature 形状
parameters:Array<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)
tsInterfaceBody
t.tsInterfaceBody(body);
另请参见 t.isTSInterfaceBody(node, opts) 和 t.assertTSInterfaceBody(node, opts)。
AST 节点 TSInterfaceBody 形状
body:Array<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:Array<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:Array<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:Array<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:Array<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,从构建器函数中排除)
别名:TypeScript,Statement,Declaration
tsNamedTupleMember
t.tsNamedTupleMember(label, elementType, optional);
另请参见 t.isTSNamedTupleMember(node, opts) 和 t.assertTSNamedTupleMember(node, opts)。
AST 节点 TSNamedTupleMember 形状
label:Identifier(必需)elementType:TSType(必需)可选:布尔值(默认: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:标识符 | 赋值模式(必需)accessibility:"public" | "private" | "protected"(默认值:null,从构建器函数中排除)decorators:Array<Decorator>(默认值:null,从构建器函数中排除)override:布尔值(默认: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"(必需)optional:boolean(默认值:null,从构建器函数中排除)readonly:boolean(默认值:null,从构建器函数中排除)
tsQualifiedName
t.tsQualifiedName(left, right);
另请参阅 t.isTSQualifiedName(node, opts) 和 t.assertTSQualifiedName(node, opts)。
AST 节点 TSQualifiedName 形状
left:TSEntityName(必需)right:标识符(必需)
tsRestType
t.tsRestType(typeAnnotation);
另请参阅 t.isTSRestType(node, opts) 和 t.assertTSRestType(node, opts)。
AST 节点 TSRestType 形状
typeAnnotation:TSType(必需)
别名:TypeScript、TSType
tsSatisfiesExpression
t.tsSatisfiesExpression(expression, typeAnnotation);
历史记录
| 版本 | 更改 |
|---|---|
v7.20.0 | 已引入 |
另请参见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
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:Array<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:Array<TSTypeElement>(必需)
别名:TypeScript、TSType
tsTypeOperator
t.tsTypeOperator(typeAnnotation);
另请参见t.isTSTypeOperator(node, opts)和t.assertTSTypeOperator(node, opts)。
AST 节点 TSTypeOperator 形状
typeAnnotation:TSType(必需)operator:string(必需)
别名:TypeScript、TSType
tsTypeParameter
t.tsTypeParameter(constraint, default, name);
历史记录
| 版本 | 更改 |
|---|---|
v7.21.0 | 支持 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:Array<TSTypeParameter>(必需)
别名:TypeScript
tsTypeParameterInstantiation
t.tsTypeParameterInstantiation(params);
另请参阅 t.isTSTypeParameterInstantiation(node, opts) 和 t.assertTSTypeParameterInstantiation(node, opts)。
AST 节点 TSTypeParameterInstantiation 形状
params:Array<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:Array<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
taggedTemplateExpression
t.taggedTemplateExpression(tag, quasi);
另请参阅 t.isTaggedTemplateExpression(node, opts) 和 t.assertTaggedTemplateExpression(node, opts)。
AST 节点 TaggedTemplateExpression 形状
tag:Expression(必需)quasi:TemplateLiteral(必需)typeParameters:TypeParameterInstantiation | TSTypeParameterInstantiation(默认值:null,从构建器函数中排除)
templateElement
t.templateElement(value, tail);
另请参阅 t.isTemplateElement(node, opts) 和 t.assertTemplateElement(node, opts)。
AST 节点 TemplateElement 形状
value:{ raw: string, cooked?: string }(必需)tail:boolean(默认值:false)
别名:Standardized
templateLiteral
t.templateLiteral(quasis, expressions);
另请参阅 t.isTemplateLiteral(node, opts) 和 t.assertTemplateLiteral(node, opts)。
AST 节点 TemplateLiteral 形状
quasis:Array<TemplateElement>(必需)expressions:Array<Expression | TSType>(必需)
别名:Standardized,Expression,Literal
thisExpression
t.thisExpression();
另请参阅 t.isThisExpression(node, opts) 和 t.assertThisExpression(node, opts)。
thisTypeAnnotation
t.thisTypeAnnotation();
另请参阅 t.isThisTypeAnnotation(node, opts) 和 t.assertThisTypeAnnotation(node, opts)。
别名:Flow、FlowType、FlowBaseAnnotation
throwStatement
t.throwStatement(argument);
另请参阅 t.isThrowStatement(node, opts) 和 t.assertThrowStatement(node, opts)。
AST 节点 ThrowStatement 形状
argument:Expression(必需)
别名:Standardized、Statement、Terminatorless、CompletionStatement
topicReference
t.topicReference();
另请参阅 t.isTopicReference(node, opts) 和 t.assertTopicReference(node, opts)。
别名:Expression
tryStatement
t.tryStatement(block, handler, finalizer);
另请参阅 t.isTryStatement(node, opts) 和 t.assertTryStatement(node, opts)。
AST 节点 TryStatement 形状
block:BlockStatement(必需)handler:CatchClause(默认值:null)finalizer:BlockStatement(默认值:null)
tupleExpression
t.tupleExpression(elements);
另请参阅 t.isTupleExpression(node, opts) 和 t.assertTupleExpression(node, opts)。
AST 节点 TupleExpression 形状
elements:Array<Expression | SpreadElement>(默认值:[])
别名:Expression
tupleTypeAnnotation
t.tupleTypeAnnotation(types);
另请参阅 t.isTupleTypeAnnotation(node, opts) 和 t.assertTupleTypeAnnotation(node, opts)。
AST 节点 TupleTypeAnnotation 形状
types:Array<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:Array<TypeParameter>(必需)
别名:Flow
typeParameterInstantiation
t.typeParameterInstantiation(params);
另请参阅 t.isTypeParameterInstantiation(node, opts) 和 t.assertTypeParameterInstantiation(node, opts)。
AST 节点 TypeParameterInstantiation 形状
params:Array<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:Array<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);
历史记录
| 版本 | 更改 |
|---|---|
v7.20.0 | kind 可以是“using”。 |
另请参阅 t.isVariableDeclaration(node, opts) 和 t.assertVariableDeclaration(node, opts)。
AST 节点 VariableDeclaration 形状
kind:"var" | "let" | "const" | "using" | "await using"(必需)declarations:Array<VariableDeclarator>(必需)declare:boolean(默认值:null,从构建器函数中排除)
别名:Standardized、Statement、Declaration
variableDeclarator
t.variableDeclarator(id, init);
另请参阅 t.isVariableDeclarator(node, opts) 和 t.assertVariableDeclarator(node, opts)。
AST 节点 VariableDeclarator 形状
id:LVal(必需)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
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(必需)
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);
涵盖的节点
Binary
BinaryExpression 和 LogicalExpression 的覆盖,它们共享相同的 AST 形状。
t.isBinary(node);
涵盖的节点
Block
已弃用。将在 Babel 8 中移除。
t.isBlock(node);
涵盖的节点
BlockParent
AST 节点的覆盖,这些节点以新的 LexicalEnvironment 开始执行上下文。换句话说,它们定义了 let 和 const 声明的范围。
t.isBlockParent(node);
涵盖的节点
ArrowFunctionExpressionBlockStatementCatchClauseClassMethodClassPrivateMethodDoWhileStatementForInStatementForOfStatementForStatement函数声明函数表达式对象方法Program静态块Switch 语句TSModuleBlockWhile 语句
类
ClassExpression 和 ClassDeclaration 的一个覆盖,它们共享相同的 AST 形状。
t.isClass(node);
涵盖的节点
完成语句
指示完成记录的语句。换句话说,它们定义了程序的控制流,例如何时应中断循环或操作引发严重错误。
t.isCompletionStatement(node);
涵盖的节点
条件
ConditionalExpression 和 IfStatement 的一个覆盖,它们共享相同的 AST 形状。
t.isConditional(node);
涵盖的节点
声明
任何声明的覆盖。
t.isDeclaration(node);
涵盖的节点
类声明声明类声明导出所有声明声明导出声明声明函数声明接口声明模块声明模块导出声明不透明类型声明类型别名声明变量枚举声明导出所有声明导出默认声明导出命名声明函数声明导入声明接口声明不透明类型TS 声明函数TS 枚举声明TS 接口声明TS 模块声明TSType 别名声明类型别名变量声明
枚举主体
Flow 枚举主体的覆盖。
t.isEnumBody(node);
涵盖的节点
枚举成员
Flow 枚举成员的覆盖。
t.isEnumMember(node);
涵盖的节点
导出声明
任何导出声明的覆盖。
t.isExportDeclaration(node);
涵盖的节点
表达式
任何表达式的覆盖。
t.isExpression(node);
涵盖的节点
数组表达式ArrowFunctionExpression赋值表达式Await 表达式BigInt 字面量BinaryExpressionBind 表达式布尔字面量调用表达式类表达式条件表达式Decimal 字面量Do 表达式函数表达式标识符导入导入表达式JSX 元素JSX 片段LogicalExpression成员表达式元属性模块表达式New 表达式Null 字面量数字字面量对象表达式可选调用表达式可选成员表达式带括号的表达式管道裸函数管道主主题引用管道主题表达式记录表达式RegExp 字面量序列表达式字符串文字超级TSA 表达式TS 实例化表达式TS 非空表达式TS 满足表达式TS 类型断言标记模板表达式模板文字此表达式主题引用元组表达式类型转换表达式一元表达式更新表达式Yield 表达式
ExpressionWrapper
没有运行时语义的表达式的包装器。
t.isExpressionWrapper(node);
涵盖的节点
Flow
为 Flow 定义的 AST 节点的覆盖。
t.isFlow(node);
涵盖的节点
AnyTypeAnnotationArrayTypeAnnotationBooleanLiteralTypeAnnotationBooleanTypeAnnotationClassImplements声明类声明导出所有声明声明导出声明声明函数声明接口声明模块声明模块导出声明不透明类型声明类型别名声明变量DeclaredPredicateEmptyTypeAnnotation枚举布尔主体枚举布尔成员枚举声明枚举默认成员枚举数字主体枚举数字成员枚举字符串主体枚举字符串成员枚举符号主体ExistsTypeAnnotationFunctionTypeAnnotationFunctionTypeParamGenericTypeAnnotationIndexedAccessTypeInferredPredicate接口声明InterfaceExtendsInterfaceTypeAnnotationIntersectionTypeAnnotationMixedTypeAnnotationNullLiteralTypeAnnotationNullableTypeAnnotationNumberLiteralTypeAnnotationNumberTypeAnnotationObjectTypeAnnotationObjectTypeCallPropertyObjectTypeIndexerObjectTypeInternalSlotObjectTypePropertyObjectTypeSpreadProperty不透明类型OptionalIndexedAccessTypeQualifiedTypeIdentifierStringLiteralTypeAnnotationStringTypeAnnotationSymbolTypeAnnotationThisTypeAnnotationTupleTypeAnnotation类型别名TypeAnnotation类型转换表达式TypeParameterTypeParameterDeclarationTypeParameterInstantiationTypeofTypeAnnotationUnionTypeAnnotationVarianceVoidTypeAnnotation
FlowBaseAnnotation
主要 Flow 型アノテーションのカバー。
t.isFlowBaseAnnotation(node);
涵盖的节点
AnyTypeAnnotationBooleanTypeAnnotationEmptyTypeAnnotationMixedTypeAnnotationNullLiteralTypeAnnotationNumberTypeAnnotationStringTypeAnnotationSymbolTypeAnnotationThisTypeAnnotationVoidTypeAnnotation
FlowDeclaration
Flow 宣言のカバー。
t.isFlowDeclaration(node);
涵盖的节点
FlowPredicate
Flow 述語のカバー。
t.isFlowPredicate(node);
涵盖的节点
FlowType
Flow 型アノテーションのカバー。
t.isFlowType(node);
涵盖的节点
AnyTypeAnnotationArrayTypeAnnotationBooleanLiteralTypeAnnotationBooleanTypeAnnotationEmptyTypeAnnotationExistsTypeAnnotationFunctionTypeAnnotationGenericTypeAnnotationIndexedAccessTypeInterfaceTypeAnnotationIntersectionTypeAnnotationMixedTypeAnnotationNullLiteralTypeAnnotationNullableTypeAnnotationNumberLiteralTypeAnnotationNumberTypeAnnotationObjectTypeAnnotationOptionalIndexedAccessTypeStringLiteralTypeAnnotationStringTypeAnnotationSymbolTypeAnnotationThisTypeAnnotationTupleTypeAnnotationTypeofTypeAnnotationUnionTypeAnnotationVoidTypeAnnotation
For
ForStatement と ForXStatement のカバー。
t.isFor(node);
涵盖的节点
ForXStatement
ForInStatements と ForOfStatements のカバー。
t.isForXStatement(node);
涵盖的节点
Function
関数と メソッド のカバー。body と params が必要です。注: Function は FunctionParent とは異なります。たとえば、StaticBlock は FunctionParent ですが Function ではありません。
t.isFunction(node);
涵盖的节点
FunctionParent
开始执行上下文的新VariableEnvironment的 AST 节点覆盖。换句话说,它们定义了var声明的范围。从 Babel 7 开始,FunctionParent 不再包含Program。
t.isFunctionParent(node);
涵盖的节点
Immutable
不可变对象和 JSX 元素的覆盖。如果创建后无法定义其他属性,则对象是不可变的。
t.isImmutable(node);
涵盖的节点
BigInt 字面量布尔字面量Decimal 字面量JSXAttributeJSXClosingElementJSXClosingFragmentJSX 元素JSXExpressionContainerJSX 片段JSXOpeningElementJSXOpeningFragmentJSXSpreadChildJSXTextNull 字面量数字字面量字符串文字
ImportOrExportDeclaration
历史记录
| 版本 | 更改 |
|---|---|
v7.21.0 | 已引入 |
ImportDeclaration 和 ExportDeclaration 的覆盖。
t.isImportOrExportDeclaration(node);
涵盖的节点
JSX
为 JSX 定义的 AST 节点的覆盖。
t.isJSX(node);
涵盖的节点
JSXAttributeJSXClosingElementJSXClosingFragmentJSX 元素JSXEmptyExpressionJSXExpressionContainerJSX 片段JSXIdentifierJSXMemberExpressionJSXNamespacedNameJSXOpeningElementJSXOpeningFragmentJSXSpreadAttributeJSXSpreadChildJSXText
LVal
赋值表达式和 ForXStatement 的left中使用的左侧表达式覆盖。
t.isLVal(node);
涵盖的节点
ArrayPatternAssignmentPattern标识符成员表达式ObjectPatternRestElementTSA 表达式TS 非空表达式TSParameterPropertyTS 满足表达式TS 类型断言
Literal
Literal、正则表达式 Literal 和 Template Literal 的覆盖。
t.isLiteral(node);
涵盖的节点
Loop
循环语句的覆盖。
t.isLoop(node);
涵盖的节点
Method
对象方法和类方法的覆盖。
t.isMethod(node);
涵盖的节点
Miscellaneous
有时对开发有用的非标准 AST 类型的覆盖。
t.isMiscellaneous(node);
涵盖的节点
ModuleDeclaration
历史记录
| 版本 | 更改 |
|---|---|
v7.21.0 | 已弃用 |
已弃用,请改用ImportOrExportDeclaration。查看 PR #15266 以获取迁移说明。
t.isModuleDeclaration(node);
涵盖的节点
ModuleSpecifier
导入和导出说明符的覆盖。注意:它不是规范中定义的 ModuleSpecifier。
t.isModuleSpecifier(node);
涵盖的节点
ExportDefaultSpecifierExportNamespaceSpecifierExportSpecifierImportDefaultSpecifierImportNamespaceSpecifierImportSpecifier
ObjectMember
对象字面量中 成员 的覆盖。
t.isObjectMember(node);
涵盖的节点
Pattern
除了标识符之外,BindingPattern 的覆盖。
t.isPattern(node);
涵盖的节点
PatternLike
BindingPattern 的一个封面
t.isPatternLike(node);
涵盖的节点
Private
私有类元素和私有标识符的一个封面。
t.isPrivate(node);
涵盖的节点
Property
对象属性和类属性的一个封面。
t.isProperty(node);
涵盖的节点
Pureish
没有副作用的 AST 节点的封面。换句话说,如果对它们进行多次评估,则没有可观察的行为变化。
t.isPureish(node);
涵盖的节点
Scopable
FunctionParent 和 BlockParent 的一个封面。
t.isScopable(node);
涵盖的节点
ArrowFunctionExpressionBlockStatementCatchClause类声明类表达式ClassMethodClassPrivateMethodDoWhileStatementForInStatementForOfStatementForStatement函数声明函数表达式对象方法Program静态块Switch 语句TSModuleBlockWhile 语句
Standardized
属于官方 ECMAScript 规范一部分的 AST 节点的封面。
t.isStandardized(node);
涵盖的节点
数组表达式ArrayPatternArrowFunctionExpression赋值表达式AssignmentPatternAwait 表达式BigInt 字面量BinaryExpressionBlockStatement布尔字面量Break 语句调用表达式CatchClauseClassAccessorPropertyClassBody类声明类表达式ClassMethodClassPrivateMethodClassPrivatePropertyClassProperty条件表达式Continue 语句DebuggerStatementDirectiveDirectiveLiteralDoWhileStatementEmptyStatement导出所有声明导出默认声明导出命名声明ExportNamespaceSpecifierExportSpecifier表达式语句FileForInStatementForOfStatementForStatement函数声明函数表达式标识符If 语句导入导入声明ImportDefaultSpecifier导入表达式ImportNamespaceSpecifierImportSpecifierInterpreterDirectiveLabeledStatementLogicalExpression成员表达式元属性New 表达式Null 字面量数字字面量对象表达式对象方法ObjectPatternObjectProperty可选调用表达式可选成员表达式带括号的表达式PrivateNameProgramRegExp 字面量RestElementReturn 语句序列表达式SpreadElement静态块字符串文字超级SwitchCaseSwitch 语句标记模板表达式TemplateElement模板文字此表达式Throw 语句TryStatement一元表达式更新表达式变量声明VariableDeclaratorWhile 语句WithStatementYield 表达式
Statement
任何 Statement 的一个封面。
t.isStatement(node);
涵盖的节点
BlockStatementBreak 语句类声明Continue 语句DebuggerStatement声明类声明导出所有声明声明导出声明声明函数声明接口声明模块声明模块导出声明不透明类型声明类型别名声明变量DoWhileStatementEmptyStatement枚举声明导出所有声明导出默认声明导出命名声明表达式语句ForInStatementForOfStatementForStatement函数声明If 语句导入声明接口声明LabeledStatement不透明类型Return 语句Switch 语句TS 声明函数TS 枚举声明TSExportAssignmentTSImportEqualsDeclarationTS 接口声明TS 模块声明TSNamespaceExportDeclarationTSType 别名声明Throw 语句TryStatement类型别名变量声明While 语句WithStatement
TSBaseType
主要 TypeScript 类型注释的一个封面。
t.isTSBaseType(node);
涵盖的节点
TSAnyKeywordTSBigIntKeywordTSBooleanKeywordTSIntrinsicKeywordTSLiteralTypeTSNeverKeywordTSNullKeywordTSNumberKeywordTSObjectKeywordTSStringKeywordTSSymbolKeywordTSThisTypeTSUndefinedKeywordTSUnknownKeywordTSVoidKeyword
TSEntityName
ts 实体的一个封面。
t.isTSEntityName(node);
涵盖的节点
TSType
TypeScript 类型注释的一个封面。
t.isTSType(node);
涵盖的节点
TSAnyKeywordTSArrayTypeTSBigIntKeywordTSBooleanKeywordTSConditionalTypeTSConstructorTypeTSExpressionWithTypeArgumentsTSFunctionTypeTSImportTypeTSIndexedAccessTypeTSInferTypeTSIntersectionTypeTSIntrinsicKeywordTSLiteralTypeTSMappedTypeTSNeverKeywordTSNullKeywordTSNumberKeywordTSObjectKeywordTSOptionalTypeTSParenthesizedTypeTSRestTypeTSStringKeywordTSSymbolKeywordTSThisTypeTSTupleTypeTSTypeLiteralTSTypeOperatorTSTypePredicateTSTypeQueryTSTypeReferenceTSUndefinedKeywordTSUnionTypeTSUnknownKeywordTSVoidKeyword
TSTypeElement
TypeScript 类型声明的一个封面。
t.isTSTypeElement(node);
涵盖的节点
TSCallSignatureDeclarationTSConstructSignatureDeclarationTSIndexSignatureTSMethodSignatureTSPropertySignature
Terminatorless
当在运算符和操作数之间插入行终止符时,其语义将发生更改的 AST 节点的封面。
t.isTerminatorless(node);
涵盖的节点
TypeScript
为 TypeScript 定义的 AST 节点的封面。
t.isTypeScript(node);
涵盖的节点
TSAnyKeywordTSArrayTypeTSA 表达式TSBigIntKeywordTSBooleanKeywordTSCallSignatureDeclarationTSConditionalTypeTSConstructSignatureDeclarationTSConstructorTypeTS 声明函数TSDeclareMethodTS 枚举声明TSEnumMemberTSExportAssignmentTSExpressionWithTypeArgumentsTSExternalModuleReferenceTSFunctionTypeTSImportEqualsDeclarationTSImportTypeTSIndexSignatureTSIndexedAccessTypeTSInferTypeTS 实例化表达式TSInterfaceBodyTS 接口声明TSIntersectionTypeTSIntrinsicKeywordTSLiteralTypeTSMappedTypeTSMethodSignatureTSModuleBlockTS 模块声明TSNamedTupleMemberTSNamespaceExportDeclarationTSNeverKeywordTS 非空表达式TSNullKeywordTSNumberKeywordTSObjectKeywordTSOptionalTypeTSParameterPropertyTSParenthesizedTypeTSPropertySignatureTSQualifiedNameTSRestTypeTS 满足表达式TSStringKeywordTSSymbolKeywordTSThisTypeTSTupleTypeTSType 别名声明TSTypeAnnotationTS 类型断言TSTypeLiteralTSTypeOperatorTSTypeParameterTSTypeParameterDeclarationTSTypeParameterInstantiationTSTypePredicateTSTypeQueryTSTypeReferenceTSUndefinedKeywordTSUnionTypeTSUnknownKeywordTSVoidKeyword
UnaryLike
UnaryExpression 和 SpreadElement 的一个封面。
t.isUnaryLike(node);
涵盖的节点
UserWhitespacable
已弃用。将在 Babel 8 中移除。
t.isUserWhitespacable(node);
涵盖的节点
对象方法ObjectPropertyObjectTypeCallPropertyObjectTypeIndexerObjectTypeInternalSlotObjectTypePropertyObjectTypeSpreadProperty
WhileJavaScriptt.isWhile(node);
t.isWhile(node);
涵盖的节点