跳至主要内容

@babel/types

此模块包含用于手动构建 AST 以及检查 AST 节点类型的方法。

安装

npm install --save-dev @babel/types

API

节点构建器

anyTypeAnnotation

JavaScript
t.anyTypeAnnotation();

另请参阅 t.isAnyTypeAnnotation(node, opts)t.assertAnyTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


argumentPlaceholder

JavaScript
t.argumentPlaceholder();

另请参阅 t.isArgumentPlaceholder(node, opts)t.assertArgumentPlaceholder(node, opts)


arrayExpression

JavaScript
t.arrayExpression(elements);

另请参阅 t.isArrayExpression(node, opts)t.assertArrayExpression(node, opts)

AST 节点 ArrayExpression 形状

  • elements: Array<null | Expression | SpreadElement>(默认值:[]

别名:StandardizedExpression


arrayPattern

JavaScript
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,从构建器函数中排除)

别名:StandardizedPatternPatternLikeLVal


arrayTypeAnnotation

JavaScript
t.arrayTypeAnnotation(elementType);

另请参阅 t.isArrayTypeAnnotation(node, opts)t.assertArrayTypeAnnotation(node, opts)

AST 节点 ArrayTypeAnnotation 形状

  • elementTypeFlowType(必需)

别名:FlowFlowType


arrowFunctionExpression

JavaScript
t.arrowFunctionExpression(params, body, async);

另请参阅 t.isArrowFunctionExpression(node, opts)t.assertArrowFunctionExpression(node, opts)

AST 节点 ArrowFunctionExpression 形状

  • paramsArray<Identifier | Pattern | RestElement>(必需)
  • bodyBlockStatement | Expression(必需)
  • asyncboolean(默认:false
  • expressionboolean(必需)
  • generatorboolean(默认:false,从构建器函数中排除)
  • predicateDeclaredPredicate | InferredPredicate(默认:null,从构建器函数中排除)
  • returnTypeTypeAnnotation | TSTypeAnnotation | Noop(默认:null,从构建器函数中排除)
  • typeParametersTypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认:null,从构建器函数中排除)

别名:StandardizedScopableFunctionBlockParentFunctionParentExpressionPureish


assignmentExpression

JavaScript
t.assignmentExpression(operator, left, right);

另请参阅 t.isAssignmentExpression(node, opts)t.assertAssignmentExpression(node, opts)

AST 节点 AssignmentExpression 形状

  • operatorstring(必需)
  • leftLVal | OptionalMemberExpression(必需)
  • rightExpression(必需)

别名:StandardizedExpression


assignmentPattern

JavaScript
t.assignmentPattern(left, right);

另请参阅 t.isAssignmentPattern(node, opts)t.assertAssignmentPattern(node, opts)

AST 节点 AssignmentPattern 形状

  • leftIdentifier | ObjectPattern | ArrayPattern | MemberExpression | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression(必需)
  • rightExpression(必需)
  • decorators: Array<Decorator>(默认值:null,从构建器函数中排除)
  • optional: boolean(默认值:null,从构建器函数中排除)
  • typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,从构建器函数中排除)

别名:StandardizedPatternPatternLikeLVal


awaitExpression

JavaScript
t.awaitExpression(argument);

另请参阅 t.isAwaitExpression(node, opts)t.assertAwaitExpression(node, opts)

AST 节点 AwaitExpression 形状

  • argumentExpression(必需)

别名:StandardizedExpressionTerminatorless


bigIntLiteral

JavaScript
t.bigIntLiteral(value);

另请参阅 t.isBigIntLiteral(node, opts)t.assertBigIntLiteral(node, opts)

AST 节点 BigIntLiteral 形状

  • valuestring(必需)

别名:StandardizedExpressionPureishLiteralImmutable


binaryExpression

JavaScript
t.binaryExpression(operator, left, right);

另请参阅 t.isBinaryExpression(node, opts)t.assertBinaryExpression(node, opts)

AST 节点 BinaryExpression 形状

  • operator"+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>"(必需)
  • leftExpression | PrivateName(必需)
  • rightExpression(必需)

别名:StandardizedBinaryExpression


bindExpression

JavaScript
t.bindExpression(object, callee);

另请参阅 t.isBindExpression(node, opts)t.assertBindExpression(node, opts)

AST 节点 BindExpression 形状

  • object: Expression(必需)
  • callee: Expression(必需)

别名:Expression


blockStatement

JavaScript
t.blockStatement(body, directives);

另请参阅 t.isBlockStatement(node, opts)t.assertBlockStatement(node, opts)

AST 节点 BlockStatement 形状

  • body: Array<Statement>(必需)
  • directives: Array<Directive>(默认值:[]

别名:StandardizedScopableBlockParentBlockStatement


booleanLiteral

JavaScript
t.booleanLiteral(value);

另请参阅 t.isBooleanLiteral(node, opts)t.assertBooleanLiteral(node, opts)

AST 节点 BooleanLiteral 形状

  • value: boolean(必需)

别名:StandardizedExpressionPureishLiteralImmutable


booleanLiteralTypeAnnotation

JavaScript
t.booleanLiteralTypeAnnotation(value);

另请参阅 t.isBooleanLiteralTypeAnnotation(node, opts)t.assertBooleanLiteralTypeAnnotation(node, opts)

AST 节点 BooleanLiteralTypeAnnotation 形状

  • value: boolean(必需)

别名:FlowFlowType


booleanTypeAnnotation

JavaScript
t.booleanTypeAnnotation();

另请参阅 t.isBooleanTypeAnnotation(node, opts)t.assertBooleanTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


breakStatement

JavaScript
t.breakStatement(label);

另请参阅 t.isBreakStatement(node, opts)t.assertBreakStatement(node, opts)

AST 节点 BreakStatement 形状

  • label: Identifier(默认值:null

别名:StandardizedStatementTerminatorlessCompletionStatement


callExpression

JavaScript
t.callExpression(callee, arguments);

另请参阅 t.isCallExpression(node, opts)t.assertCallExpression(node, opts)

AST 节点 CallExpression 形状

  • callee: Expression | Super | V8IntrinsicIdentifier(必需)
  • arguments: Array<Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder>(必需)
  • optional: true | false(默认值:null,从生成器函数中排除)
  • typeArguments: TypeParameterInstantiation(默认值:null,从生成器函数中排除)
  • typeParameters: TSTypeParameterInstantiation(默认值:null,从生成器函数中排除)

别名:StandardizedExpression


catchClause

JavaScript
t.catchClause(param, body);

另请参阅 t.isCatchClause(node, opts)t.assertCatchClause(node, opts)

AST 节点 CatchClause 形状

  • param: Identifier | ArrayPattern | ObjectPattern(默认值:null
  • body: BlockStatement(必需)

别名:StandardizedScopableBlockParent


classAccessorProperty

JavaScript
t.classAccessorProperty(key, value, typeAnnotation, decorators, computed, static);

另请参阅 t.isClassAccessorProperty(node, opts)t.assertClassAccessorProperty(node, opts)

AST 节点 ClassAccessorProperty 形状

  • key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression | PrivateName(必需)
  • value: Expression(默认值: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,从构建器函数中排除)

别名:StandardizedPropertyAccessor


classBody

JavaScript
t.classBody(body);

另请参阅 t.isClassBody(node, opts)t.assertClassBody(node, opts)

AST 节点 ClassBody 形状

  • body: Array<ClassMethod | ClassPrivateMethod | ClassProperty | ClassPrivateProperty | ClassAccessorProperty | TSDeclareMethod | TSIndexSignature | StaticBlock>(必需)

别名:Standardized


classDeclaration

JavaScript
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,从构建器函数中排除)
  • typeParametersTypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认:null,从构建器函数中排除)

别名:StandardizedScopableClassStatementDeclaration


classExpression

JavaScript
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,从构建器函数中排除)
  • typeParametersTypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认:null,从构建器函数中排除)

别名:StandardizedScopableClassExpression


classImplements

JavaScript
t.classImplements(id, typeParameters);

另请参阅 t.isClassImplements(node, opts)t.assertClassImplements(node, opts)

AST 节点 ClassImplements 形状

  • id: Identifier(必需)
  • typeParameters: TypeParameterInstantiation(默认值:null

别名:Flow


classMethod

JavaScript
t.classMethod(kind, key, params, body, computed, static, generator, async);

另请参阅 t.isClassMethod(node, opts)t.assertClassMethod(node, opts)

AST 节点 ClassMethod 形状

  • kind: "get" | "set" | "method" | "constructor"(默认值:'method'
  • key: 如果计算则为 Expression,否则为 Identifier | Literal(必需)
  • params: Array<Identifier | Pattern | RestElement | TSParameterProperty>(必需)
  • body: BlockStatement(必需)
  • computed: boolean(默认值:false
  • static: boolean(默认值:false
  • generator: boolean(默认值:false
  • asyncboolean(默认:false
  • abstract: boolean(默认值:null,从构建器函数中排除)
  • access: "public" | "private" | "protected"(默认值:null,从构建器函数中排除)
  • accessibility: "public" | "private" | "protected"(默认值:null,从构建器函数中排除)
  • decorators: Array<Decorator>(默认值:null,从构建器函数中排除)
  • optional: boolean(默认值:null,从构建器函数中排除)
  • override: boolean(默认值:false,从构建器函数中排除)
  • returnTypeTypeAnnotation | TSTypeAnnotation | Noop(默认:null,从构建器函数中排除)
  • typeParametersTypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认:null,从构建器函数中排除)

别名:StandardizedFunctionScopableBlockParentFunctionParentMethod


classPrivateMethod

JavaScript
t.classPrivateMethod(kind, key, params, body, static);

另请参阅 t.isClassPrivateMethod(node, opts)t.assertClassPrivateMethod(node, opts)

AST 节点 ClassPrivateMethod 形状

  • kind"get" | "set" | "method"(默认:'method'
  • keyPrivateName(必需)
  • params: Array<Identifier | Pattern | RestElement | TSParameterProperty>(必需)
  • body: BlockStatement(必需)
  • static: boolean(默认值:false
  • abstract: boolean(默认值:null,从构建器函数中排除)
  • access: "public" | "private" | "protected"(默认值:null,从构建器函数中排除)
  • accessibility: "public" | "private" | "protected"(默认值:null,从构建器函数中排除)
  • asyncboolean(默认:false,从构建器函数中排除)
  • computed:'false'(默认:false,从构建器函数中排除)
  • decorators: Array<Decorator>(默认值:null,从构建器函数中排除)
  • generatorboolean(默认:false,从构建器函数中排除)
  • optional: boolean(默认值:null,从构建器函数中排除)
  • override: boolean(默认值:false,从构建器函数中排除)
  • returnTypeTypeAnnotation | TSTypeAnnotation | Noop(默认:null,从构建器函数中排除)
  • typeParametersTypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认:null,从构建器函数中排除)

别名:StandardizedFunctionScopableBlockParentFunctionParentMethodPrivate


classPrivateProperty

JavaScript
t.classPrivateProperty(key, value, decorators, static);

另请参阅 t.isClassPrivateProperty(node, opts)t.assertClassPrivateProperty(node, opts)

AST 节点 ClassPrivateProperty 形状

  • keyPrivateName(必需)
  • value: Expression(默认值:null
  • decorators: Array<Decorator>(默认值:null
  • static: boolean(默认值:false
  • definite: boolean(默认值:null,从构建器函数中排除)
  • readonly: boolean(默认值:null,从构建器函数中排除)
  • typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,从构建器函数中排除)
  • variance: Variance(默认值:null,从构建器函数中排除)

别名:StandardizedPropertyPrivate


classProperty

JavaScript
t.classProperty(key, value, typeAnnotation, decorators, computed, static);
历史记录
版本更改
v7.6.0支持 static

另请参阅 t.isClassProperty(node, opts)t.assertClassProperty(node, opts)

AST 节点 ClassProperty 形状

  • keyIdentifier | 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,从构建器函数中排除)

别名:StandardizedProperty


conditionalExpression

JavaScript
t.conditionalExpression(test, consequent, alternate);

另请参阅 t.isConditionalExpression(node, opts)t.assertConditionalExpression(node, opts)

AST 节点 ConditionalExpression 形状

  • testExpression(必需)
  • consequentExpression(必需)
  • alternateExpression(必需)

别名:StandardizedExpressionConditional


continueStatement

JavaScript
t.continueStatement(label);

另请参阅 t.isContinueStatement(node, opts)t.assertContinueStatement(node, opts)

AST 节点 ContinueStatement 形状

  • label: Identifier(默认值:null

别名:StandardizedStatementTerminatorlessCompletionStatement


debuggerStatement

JavaScript
t.debuggerStatement();

另请参阅 t.isDebuggerStatement(node, opts)t.assertDebuggerStatement(node, opts)

别名:StandardizedStatement


decimalLiteral

JavaScript
t.decimalLiteral(value);

另请参阅 t.isDecimalLiteral(node, opts)t.assertDecimalLiteral(node, opts)

AST 节点 DecimalLiteral 形状

  • valuestring(必需)

别名:ExpressionPureishLiteralImmutable


declareClass

JavaScript
t.declareClass(id, typeParameters, extends, body);

另请参阅 t.isDeclareClass(node, opts)t.assertDeclareClass(node, opts)

AST 节点 DeclareClass 形状

  • id: Identifier(必需)
  • typeParametersTypeParameterDeclaration(默认:null
  • extendsArray<InterfaceExtends>(默认:null
  • body: ObjectTypeAnnotation(必需)
  • implements: Array<ClassImplements>(默认值:null,从构建器函数中排除)
  • mixins: Array<InterfaceExtends>(默认值:null,从构建器函数中排除)

别名:FlowFlowDeclarationStatementDeclaration


declareExportAllDeclaration

JavaScript
t.declareExportAllDeclaration(source);

另请参阅 t.isDeclareExportAllDeclaration(node, opts)t.assertDeclareExportAllDeclaration(node, opts)

AST 节点 DeclareExportAllDeclaration 形状

  • source: StringLiteral(必需)
  • exportKind: "type" | "value"(默认值:null,从构建器函数中排除)

别名:FlowFlowDeclarationStatementDeclaration


declareExportDeclaration

JavaScript
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,从构建器函数中排除)

别名:FlowFlowDeclarationStatementDeclaration


declareFunction

JavaScript
t.declareFunction(id);

另请参阅 t.isDeclareFunction(node, opts)t.assertDeclareFunction(node, opts)

AST 节点 DeclareFunction 形状

  • id: Identifier(必需)
  • predicate: DeclaredPredicate(默认值:null,从构建器函数中排除)

别名:FlowFlowDeclarationStatementDeclaration


declareInterface

JavaScript
t.declareInterface(id, typeParameters, extends, body);

另请参阅 t.isDeclareInterface(node, opts)t.assertDeclareInterface(node, opts)

AST 节点 DeclareInterface 形状

  • id: Identifier(必需)
  • typeParametersTypeParameterDeclaration(默认:null
  • extendsArray<InterfaceExtends>(默认:null
  • body: ObjectTypeAnnotation(必需)

别名:FlowFlowDeclarationStatementDeclaration


declareModule

JavaScript
t.declareModule(id, body, kind);

另请参阅 t.isDeclareModule(node, opts)t.assertDeclareModule(node, opts)

AST 节点 DeclareModule 形状

  • id: Identifier | StringLiteral(必需)
  • body: BlockStatement(必需)
  • kind: "CommonJS" | "ES"(默认值:null

别名:FlowFlowDeclarationStatementDeclaration


declareModuleExports

JavaScript
t.declareModuleExports(typeAnnotation);

另请参阅 t.isDeclareModuleExports(node, opts)t.assertDeclareModuleExports(node, opts)

AST 节点 DeclareModuleExports 形状

  • typeAnnotation: TypeAnnotation(必需)

别名:FlowFlowDeclarationStatementDeclaration


declareOpaqueType

JavaScript
t.declareOpaqueType(id, typeParameters, supertype);

另请参阅 t.isDeclareOpaqueType(node, opts)t.assertDeclareOpaqueType(node, opts)

AST 节点 DeclareOpaqueType 形状

  • id: Identifier(必需)
  • typeParametersTypeParameterDeclaration(默认:null
  • supertype: FlowType(默认值:null
  • impltype: FlowType(默认值:null,从构建器函数中排除)

别名:FlowFlowDeclarationStatementDeclaration


declareTypeAlias

JavaScript
t.declareTypeAlias(id, typeParameters, right);

另请参阅 t.isDeclareTypeAlias(node, opts)t.assertDeclareTypeAlias(node, opts)

AST 节点 DeclareTypeAlias 形状

  • id: Identifier(必需)
  • typeParametersTypeParameterDeclaration(默认:null
  • right: FlowType(必需)

别名:FlowFlowDeclarationStatementDeclaration


declareVariable

JavaScript
t.declareVariable(id);

另请参阅 t.isDeclareVariable(node, opts)t.assertDeclareVariable(node, opts)

AST 节点 DeclareVariable 形状

  • id: Identifier(必需)

别名:FlowFlowDeclarationStatementDeclaration


declaredPredicate

JavaScript
t.declaredPredicate(value);

另请参阅 t.isDeclaredPredicate(node, opts)t.assertDeclaredPredicate(node, opts)

AST 节点 DeclaredPredicate 形状

  • value: Flow(必需)

别名:FlowFlowPredicate


装饰器

JavaScript
t.decorator(expression);

另请参见 t.isDecorator(node, opts)t.assertDecorator(node, opts)

AST 节点 Decorator 形状

  • expressionExpression(必需)

指令

JavaScript
t.directive(value);

另请参见 t.isDirective(node, opts)t.assertDirective(node, opts)

AST 节点 Directive 形状

  • valueDirectiveLiteral(必需)

别名:Standardized


指令文本

JavaScript
t.directiveLiteral(value);

另请参见 t.isDirectiveLiteral(node, opts)t.assertDirectiveLiteral(node, opts)

AST 节点 DirectiveLiteral 形状

  • valuestring(必需)

别名:Standardized


do 表达式

JavaScript
t.doExpression(body, async);

另请参见 t.isDoExpression(node, opts)t.assertDoExpression(node, opts)

AST 节点 DoExpression 形状

  • body: BlockStatement(必需)
  • asyncboolean(默认:false

别名:Expression


do while 语句

JavaScript
t.doWhileStatement(test, body);

另请参见 t.isDoWhileStatement(node, opts)t.assertDoWhileStatement(node, opts)

AST 节点 DoWhileStatement 形状

  • testExpression(必需)
  • bodyStatement(必需)

别名:StandardizedStatementBlockParentLoopWhileScopable


空语句

JavaScript
t.emptyStatement();

另请参见 t.isEmptyStatement(node, opts)t.assertEmptyStatement(node, opts)

别名:StandardizedStatement


空类型注释

JavaScript
t.emptyTypeAnnotation();

另请参见 t.isEmptyTypeAnnotation(node, opts)t.assertEmptyTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


枚举布尔正文

JavaScript
t.enumBooleanBody(members);

另请参见 t.isEnumBooleanBody(node, opts)t.assertEnumBooleanBody(node, opts)

AST 节点 EnumBooleanBody 形状

  • membersArray<EnumBooleanMember>(必需)
  • explicitTypeboolean(必需)
  • hasUnknownMembersboolean(必需)

别名:FlowEnumBody


枚举布尔成员

JavaScript
t.enumBooleanMember(id);

另请参见 t.isEnumBooleanMember(node, opts)t.assertEnumBooleanMember(node, opts)

AST 节点 EnumBooleanMember 形状

  • id: Identifier(必需)
  • initBooleanLiteral(必需)

别名:FlowEnumMember


枚举声明

JavaScript
t.enumDeclaration(id, body);

另请参见 t.isEnumDeclaration(node, opts)t.assertEnumDeclaration(node, opts)

AST 节点 EnumDeclaration 形状

  • id: Identifier(必需)
  • bodyEnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody(必需)

别名:FlowStatementDeclaration


枚举默认成员

JavaScript
t.enumDefaultedMember(id);

另请参见 t.isEnumDefaultedMember(node, opts)t.assertEnumDefaultedMember(node, opts)

AST 节点 EnumDefaultedMember 形状

  • id: Identifier(必需)

别名:FlowEnumMember


枚举数字正文

JavaScript
t.enumNumberBody(members);

另请参见 t.isEnumNumberBody(node, opts)t.assertEnumNumberBody(node, opts)

AST 节点 EnumNumberBody 形状

  • membersArray<EnumNumberMember>(必需)
  • explicitTypeboolean(必需)
  • hasUnknownMembersboolean(必需)

别名:FlowEnumBody


enumNumberMember

JavaScript
t.enumNumberMember(id, init);

另请参阅 t.isEnumNumberMember(node, opts)t.assertEnumNumberMember(node, opts)

AST 节点 EnumNumberMember 形状

  • id: Identifier(必需)
  • init: NumericLiteral(必需)

别名:FlowEnumMember


enumStringBody

JavaScript
t.enumStringBody(members);

另请参阅 t.isEnumStringBody(node, opts)t.assertEnumStringBody(node, opts)

AST 节点 EnumStringBody 形状

  • members: Array<EnumStringMember | EnumDefaultedMember>(必需)
  • explicitTypeboolean(必需)
  • hasUnknownMembersboolean(必需)

别名:FlowEnumBody


enumStringMember

JavaScript
t.enumStringMember(id, init);

另请参阅 t.isEnumStringMember(node, opts)t.assertEnumStringMember(node, opts)

AST 节点 EnumStringMember 形状

  • id: Identifier(必需)
  • init: StringLiteral(必需)

别名:FlowEnumMember


enumSymbolBody

JavaScript
t.enumSymbolBody(members);

另请参阅 t.isEnumSymbolBody(node, opts)t.assertEnumSymbolBody(node, opts)

AST 节点 EnumSymbolBody 形状

  • members: Array<EnumDefaultedMember>(必需)
  • hasUnknownMembersboolean(必需)

别名:FlowEnumBody


existsTypeAnnotation

JavaScript
t.existsTypeAnnotation();

另请参阅 t.isExistsTypeAnnotation(node, opts)t.assertExistsTypeAnnotation(node, opts)

别名:FlowFlowType


exportAllDeclaration

JavaScript
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,从构建器函数中排除)

别名:StandardizedStatementDeclarationImportOrExportDeclarationExportDeclaration


exportDefaultDeclaration

JavaScript
t.exportDefaultDeclaration(declaration);

另请参阅 t.isExportDefaultDeclaration(node, opts)t.assertExportDefaultDeclaration(node, opts)

AST 节点 ExportDefaultDeclaration 形状

  • declaration: TSDeclareFunction | FunctionDeclaration | ClassDeclaration | Expression(必需)
  • exportKind: "value"(默认值:null,从构建器函数中排除)

别名:StandardizedStatementDeclarationImportOrExportDeclarationExportDeclaration


exportDefaultSpecifier

JavaScript
t.exportDefaultSpecifier(exported);

另请参阅 t.isExportDefaultSpecifier(node, opts)t.assertExportDefaultSpecifier(node, opts)

AST 节点 ExportDefaultSpecifier 形状

  • exported: Identifier(必需)

别名:ModuleSpecifier


exportNamedDeclaration

JavaScript
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,从构建器函数中排除)

别名:StandardizedStatementDeclarationImportOrExportDeclarationExportDeclaration


exportNamespaceSpecifier

JavaScript
t.exportNamespaceSpecifier(exported);

另请参阅 t.isExportNamespaceSpecifier(node, opts)t.assertExportNamespaceSpecifier(node, opts)

AST 节点 ExportNamespaceSpecifier 形状

  • exported: Identifier(必需)

别名:StandardizedModuleSpecifier


exportSpecifier

JavaScript
t.exportSpecifier(local, exported);

另请参阅 t.isExportSpecifier(node, opts)t.assertExportSpecifier(node, opts)

AST 节点 ExportSpecifier 形状

  • local: Identifier(必需)
  • exported: 标识符 | 字符串字面量(必需)
  • exportKind: "type" | "value"(默认值:null,从构建器函数中排除)

别名:StandardizedModuleSpecifier


expressionStatement

JavaScript
t.expressionStatement(expression);

另请参阅 t.isExpressionStatement(node, opts)t.assertExpressionStatement(node, opts)

AST 节点 ExpressionStatement 形状

  • expressionExpression(必需)

别名:StandardizedStatementExpressionWrapper


file

JavaScript
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

JavaScript
t.forInStatement(left, right, body);

另请参阅 t.isForInStatement(node, opts)t.assertForInStatement(node, opts)

AST 节点 ForInStatement 形状

  • left: VariableDeclaration | LVal(必需)
  • rightExpression(必需)
  • bodyStatement(必需)

别名:StandardizedScopableStatementForBlockParentLoopForXStatement


forOfStatement

JavaScript
t.forOfStatement(left, right, body, await);

另请参阅 t.isForOfStatement(node, opts)t.assertForOfStatement(node, opts)

AST 节点 ForOfStatement 形状

  • left: VariableDeclaration | LVal(必需)
  • rightExpression(必需)
  • bodyStatement(必需)
  • await: boolean(默认值:false

别名:StandardizedScopableStatementForBlockParentLoopForXStatement


forStatement

JavaScript
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
  • bodyStatement(必需)

别名:StandardizedScopableStatementForBlockParentLoop


functionDeclaration

JavaScript
t.functionDeclaration(id, params, body, generator, async);

另请参阅 t.isFunctionDeclaration(node, opts)t.assertFunctionDeclaration(node, opts)

AST 节点 FunctionDeclaration 形状

  • id: Identifier(默认值:null
  • paramsArray<Identifier | Pattern | RestElement>(必需)
  • body: BlockStatement(必需)
  • generator: boolean(默认值:false
  • asyncboolean(默认:false
  • declare: boolean(默认值:null,从构建器函数中排除)
  • predicateDeclaredPredicate | InferredPredicate(默认:null,从构建器函数中排除)
  • returnTypeTypeAnnotation | TSTypeAnnotation | Noop(默认:null,从构建器函数中排除)
  • typeParametersTypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认:null,从构建器函数中排除)

别名:StandardizedScopableFunctionBlockParentFunctionParentStatementPureishDeclaration


functionExpression

JavaScript
t.functionExpression(id, params, body, generator, async);

另请参阅 t.isFunctionExpression(node, opts)t.assertFunctionExpression(node, opts)

AST 节点 FunctionExpression 形状

  • id: Identifier(默认值:null
  • paramsArray<Identifier | Pattern | RestElement>(必需)
  • body: BlockStatement(必需)
  • generator: boolean(默认值:false
  • asyncboolean(默认:false
  • predicateDeclaredPredicate | InferredPredicate(默认:null,从构建器函数中排除)
  • returnTypeTypeAnnotation | TSTypeAnnotation | Noop(默认:null,从构建器函数中排除)
  • typeParametersTypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认:null,从构建器函数中排除)

别名:StandardizedScopableFunctionBlockParentFunctionParentExpressionPureish


functionTypeAnnotation

JavaScript
t.functionTypeAnnotation(typeParameters, params, rest, returnType);

另请参阅 t.isFunctionTypeAnnotation(node, opts)t.assertFunctionTypeAnnotation(node, opts)

AST 节点 FunctionTypeAnnotation 形状

  • typeParametersTypeParameterDeclaration(默认:null
  • params: Array<FunctionTypeParam>(必需)
  • rest: FunctionTypeParam(默认值:null
  • returnType: FlowType(必需)
  • this: FunctionTypeParam(默认值:null,从生成器函数中排除)

别名:FlowFlowType


functionTypeParam

JavaScript
t.functionTypeParam(name, typeAnnotation);

另请参阅 t.isFunctionTypeParam(node, opts)t.assertFunctionTypeParam(node, opts)

AST 节点 FunctionTypeParam 形状

  • name: Identifier(默认值:null
  • typeAnnotation: FlowType(必需)
  • optional: boolean(默认值:null,从构建器函数中排除)

别名:Flow


genericTypeAnnotation

JavaScript
t.genericTypeAnnotation(id, typeParameters);

另请参阅 t.isGenericTypeAnnotation(node, opts)t.assertGenericTypeAnnotation(node, opts)

AST 节点 GenericTypeAnnotation 形状

  • id: Identifier | QualifiedTypeIdentifier(必需)
  • typeParameters: TypeParameterInstantiation(默认值:null

别名:FlowFlowType


identifier

JavaScript
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,从构建器函数中排除)

别名:StandardizedExpressionPatternLikeLValTSEntityName


ifStatement

JavaScript
t.ifStatement(test, consequent, alternate);

另请参阅 t.isIfStatement(node, opts)t.assertIfStatement(node, opts)

AST 节点 IfStatement 形状

  • testExpression(必需)
  • consequent: Statement(必需)
  • alternate: Statement(默认值:null

别名:StandardizedStatementConditional


import

JavaScript
t.import();

另请参阅 t.isImport(node, opts)t.assertImport(node, opts)

别名:StandardizedExpression


importAttribute

JavaScript
t.importAttribute(key, value);

另请参阅 t.isImportAttribute(node, opts)t.assertImportAttribute(node, opts)

AST 节点 ImportAttribute 形状

  • key: Identifier | StringLiteral(必需)
  • value: StringLiteral(必需)

importDeclaration

JavaScript
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,从生成器函数中排除)

别名:StandardizedStatementDeclarationImportOrExportDeclaration


importDefaultSpecifier

JavaScript
t.importDefaultSpecifier(local);

另请参阅 t.isImportDefaultSpecifier(node, opts)t.assertImportDefaultSpecifier(node, opts)

AST 节点 ImportDefaultSpecifier 形状

  • local: Identifier(必需)

别名:StandardizedModuleSpecifier


importExpression

JavaScript
t.importExpression(source, options);

另请参阅 t.isImportExpression(node, opts)t.assertImportExpression(node, opts)

AST 节点 ImportExpression 形状

  • source: Expression(必需)
  • options: Expression(默认值:null
  • phase: "source" | "defer"(默认值:null,从生成器函数中排除)

别名:StandardizedExpression


importNamespaceSpecifier

JavaScript
t.importNamespaceSpecifier(local);

另请参阅 t.isImportNamespaceSpecifier(node, opts)t.assertImportNamespaceSpecifier(node, opts)

AST 节点 ImportNamespaceSpecifier 形状

  • local: Identifier(必需)

别名:StandardizedModuleSpecifier


importSpecifier

JavaScript
t.importSpecifier(local, imported);

另请参见 t.isImportSpecifier(node, opts)t.assertImportSpecifier(node, opts)

AST 节点 ImportSpecifier 形状

  • local: Identifier(必需)
  • imported: Identifier | StringLiteral(必需)
  • importKind: "type" | "typeof" | "value"(默认值:null,从生成器函数中排除)

别名:StandardizedModuleSpecifier


indexedAccessType

JavaScript
t.indexedAccessType(objectType, indexType);

另请参见 t.isIndexedAccessType(node, opts)t.assertIndexedAccessType(node, opts)

AST 节点 IndexedAccessType 形状

  • objectType: FlowType(必需)
  • indexType: FlowType(必需)

别名:FlowFlowType


inferredPredicate

JavaScript
t.inferredPredicate();

另请参见 t.isInferredPredicate(node, opts)t.assertInferredPredicate(node, opts)

别名:FlowFlowPredicate


interfaceDeclaration

JavaScript
t.interfaceDeclaration(id, typeParameters, extends, body);

另请参见 t.isInterfaceDeclaration(node, opts)t.assertInterfaceDeclaration(node, opts)

AST 节点 InterfaceDeclaration 形状

  • id: Identifier(必需)
  • typeParametersTypeParameterDeclaration(默认:null
  • extendsArray<InterfaceExtends>(默认:null
  • body: ObjectTypeAnnotation(必需)

别名:FlowFlowDeclarationStatementDeclaration


interfaceExtends

JavaScript
t.interfaceExtends(id, typeParameters);

另请参见 t.isInterfaceExtends(node, opts)t.assertInterfaceExtends(node, opts)

AST 节点 InterfaceExtends 形状

  • id: Identifier | QualifiedTypeIdentifier(必需)
  • typeParameters: TypeParameterInstantiation(默认值:null

别名:Flow


interfaceTypeAnnotation

JavaScript
t.interfaceTypeAnnotation(extends, body);

另请参见 t.isInterfaceTypeAnnotation(node, opts)t.assertInterfaceTypeAnnotation(node, opts)

AST 节点 InterfaceTypeAnnotation 形状

  • extendsArray<InterfaceExtends>(默认:null
  • body: ObjectTypeAnnotation(必需)

别名:FlowFlowType


interpreterDirective

JavaScript
t.interpreterDirective(value);

另请参见 t.isInterpreterDirective(node, opts)t.assertInterpreterDirective(node, opts)

AST 节点 InterpreterDirective 形状

  • valuestring(必需)

别名:Standardized


intersectionTypeAnnotation

JavaScript
t.intersectionTypeAnnotation(types);

另请参见 t.isIntersectionTypeAnnotation(node, opts)t.assertIntersectionTypeAnnotation(node, opts)

AST 节点 IntersectionTypeAnnotation 形状

  • types: Array<FlowType>(必需)

别名:FlowFlowType


jsxAttribute

JavaScript
t.jsxAttribute(name, value);

另请参见 t.isJSXAttribute(node, opts)t.assertJSXAttribute(node, opts)

AST 节点 JSXAttribute 形状

  • name: JSXIdentifier | JSXNamespacedName(必需)
  • value: JSXElement | JSXFragment | StringLiteral | JSXExpressionContainer(默认值:null

别名:JSXImmutable


jsxClosingElement

JavaScript
t.jsxClosingElement(name);

另请参见 t.isJSXClosingElement(node, opts)t.assertJSXClosingElement(node, opts)

AST 节点 JSXClosingElement 形状

  • name: JSXIdentifier | JSXMemberExpression | JSXNamespacedName(必需)

别名:JSXImmutable


jsxClosingFragment

JavaScript
t.jsxClosingFragment();

另请参见 t.isJSXClosingFragment(node, opts)t.assertJSXClosingFragment(node, opts)

别名:JSXImmutable


jsxElement

JavaScript
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

别名:JSXImmutableExpression


jsxEmptyExpression

JavaScript
t.jsxEmptyExpression();

另请参阅 t.isJSXEmptyExpression(node, opts)t.assertJSXEmptyExpression(node, opts)

别名:JSX


jsxExpressionContainer

JavaScript
t.jsxExpressionContainer(expression);

另请参阅 t.isJSXExpressionContainer(node, opts)t.assertJSXExpressionContainer(node, opts)

AST 节点 JSXExpressionContainer 形状

  • expression: Expression | JSXEmptyExpression(必需)

别名:JSXImmutable


jsxFragment

JavaScript
t.jsxFragment(openingFragment, closingFragment, children);

另请参阅 t.isJSXFragment(node, opts)t.assertJSXFragment(node, opts)

AST 节点 JSXFragment 形状

  • openingFragment: JSXOpeningFragment(必需)
  • closingFragment: JSXClosingFragment(必需)
  • children: Array<JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment>(必需)

别名:JSXImmutableExpression


jsxIdentifier

JavaScript
t.jsxIdentifier(name);

另请参阅 t.isJSXIdentifier(node, opts)t.assertJSXIdentifier(node, opts)

AST 节点 JSXIdentifier 形状

  • name: string(必需)

别名:JSX


jsxMemberExpression

JavaScript
t.jsxMemberExpression(object, property);

另请参阅 t.isJSXMemberExpression(node, opts)t.assertJSXMemberExpression(node, opts)

AST 节点 JSXMemberExpression 形状

  • object: JSXMemberExpression | JSXIdentifier(必需)
  • property: JSXIdentifier(必需)

别名:JSX


jsxNamespacedName

JavaScript
t.jsxNamespacedName(namespace, name);

另请参阅 t.isJSXNamespacedName(node, opts)t.assertJSXNamespacedName(node, opts)

AST 节点 JSXNamespacedName 形状

  • namespace: JSXIdentifier(必需)
  • name: JSXIdentifier(必需)

别名:JSX


jsxOpeningElement

JavaScript
t.jsxOpeningElement(name, attributes, selfClosing);

另请参阅 t.isJSXOpeningElement(node, opts)t.assertJSXOpeningElement(node, opts)

AST 节点 JSXOpeningElement 形状

  • name: JSXIdentifier | JSXMemberExpression | JSXNamespacedName(必需)
  • attributes: Array<JSXAttribute | JSXSpreadAttribute>(必需)
  • selfClosing: boolean(默认值:false
  • typeParameters: TypeParameterInstantiation | TSTypeParameterInstantiation(默认值:null,从构建器函数中排除)

别名:JSXImmutable


jsxOpeningFragment

JavaScript
t.jsxOpeningFragment();

另请参阅 t.isJSXOpeningFragment(node, opts)t.assertJSXOpeningFragment(node, opts)

别名:JSXImmutable


jsxSpreadAttribute

JavaScript
t.jsxSpreadAttribute(argument);

另请参阅 t.isJSXSpreadAttribute(node, opts)t.assertJSXSpreadAttribute(node, opts)

AST 节点 JSXSpreadAttribute 形状

  • argumentExpression(必需)

别名:JSX


jsxSpreadChild

JavaScript
t.jsxSpreadChild(expression);

另请参阅 t.isJSXSpreadChild(node, opts)t.assertJSXSpreadChild(node, opts)

AST 节点 JSXSpreadChild 形状

  • expressionExpression(必需)

别名:JSXImmutable


jsxText

JavaScript
t.jsxText(value);

另请参阅 t.isJSXText(node, opts)t.assertJSXText(node, opts)

AST 节点 JSXText 形状

  • valuestring(必需)

别名:JSXImmutable


labeledStatement

JavaScript
t.labeledStatement(label, body);

另请参阅 t.isLabeledStatement(node, opts)t.assertLabeledStatement(node, opts)

AST 节点 LabeledStatement 形状

  • label: Identifier(必需)
  • bodyStatement(必需)

别名:StandardizedStatement


逻辑表达式

JavaScript
t.logicalExpression(operator, left, right);

另请参阅 t.isLogicalExpression(node, opts)t.assertLogicalExpression(node, opts)

AST 节点 LogicalExpression 形状

  • operator: "||" | "&&" | "??"(必需)
  • left: Expression(必需)
  • rightExpression(必需)

别名:StandardizedBinaryExpression


成员表达式

JavaScript
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

别名:StandardizedExpressionLVal


元属性

JavaScript
t.metaProperty(meta, property);

另请参阅 t.isMetaProperty(node, opts)t.assertMetaProperty(node, opts)

AST 节点 MetaProperty 形状

  • meta: Identifier(必需)
  • property: Identifier(必需)

别名:StandardizedExpression


混合类型注解

JavaScript
t.mixedTypeAnnotation();

另请参阅 t.isMixedTypeAnnotation(node, opts)t.assertMixedTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


模块表达式

JavaScript
t.moduleExpression(body);

另请参阅 t.isModuleExpression(node, opts)t.assertModuleExpression(node, opts)

AST 节点 ModuleExpression 形状

  • body: Program(必需)

别名:Expression


新表达式

JavaScript
t.newExpression(callee, arguments);

另请参阅 t.isNewExpression(node, opts)t.assertNewExpression(node, opts)

AST 节点 NewExpression 形状

  • callee: Expression | Super | V8IntrinsicIdentifier(必需)
  • arguments: Array<Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder>(必需)
  • optional: true | false(默认值:null,从生成器函数中排除)
  • typeArguments: TypeParameterInstantiation(默认值:null,从生成器函数中排除)
  • typeParameters: TSTypeParameterInstantiation(默认值:null,从生成器函数中排除)

别名:StandardizedExpression


空操作

JavaScript
t.noop();

另请参阅 t.isNoop(node, opts)t.assertNoop(node, opts)

别名:Miscellaneous


空文字

JavaScript
t.nullLiteral();

另请参阅 t.isNullLiteral(node, opts)t.assertNullLiteral(node, opts)

别名:StandardizedExpressionPureishLiteralImmutable


空文字类型注解

JavaScript
t.nullLiteralTypeAnnotation();

另请参阅 t.isNullLiteralTypeAnnotation(node, opts)t.assertNullLiteralTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


可空类型注解

JavaScript
t.nullableTypeAnnotation(typeAnnotation);

另请参阅 t.isNullableTypeAnnotation(node, opts)t.assertNullableTypeAnnotation(node, opts)

AST 节点 NullableTypeAnnotation 形状

  • typeAnnotation: FlowType(必需)

别名:FlowFlowType


数字文字类型注解

JavaScript
t.numberLiteralTypeAnnotation(value);

另请参阅 t.isNumberLiteralTypeAnnotation(node, opts)t.assertNumberLiteralTypeAnnotation(node, opts)

AST 节点 NumberLiteralTypeAnnotation 形状

  • value: number(必需)

别名:FlowFlowType


数字类型注解

JavaScript
t.numberTypeAnnotation();

另请参阅 t.isNumberTypeAnnotation(node, opts)t.assertNumberTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


数字文字

JavaScript
t.numericLiteral(value);

另请参阅t.isNumericLiteral(node, opts)t.assertNumericLiteral(node, opts)

AST 节点NumericLiteral形状

  • value:非负有限number(必需)

别名:StandardizedExpressionPureishLiteralImmutable


对象表达式

JavaScript
t.objectExpression(properties);

另请参阅t.isObjectExpression(node, opts)t.assertObjectExpression(node, opts)

AST 节点ObjectExpression形状

  • propertiesArray<ObjectMethod | ObjectProperty | SpreadElement>(必需)

别名:StandardizedExpression


对象方法

JavaScript
t.objectMethod(kind, key, params, body, computed, generator, async);

另请参阅t.isObjectMethod(node, opts)t.assertObjectMethod(node, opts)

AST 节点ObjectMethod形状

  • kind"method" | "get" | "set"(默认:'method'
  • key: 如果计算则为 Expression,否则为 Identifier | Literal(必需)
  • paramsArray<Identifier | Pattern | RestElement>(必需)
  • body: BlockStatement(必需)
  • computed: boolean(默认值:false
  • generator: boolean(默认值:false
  • asyncboolean(默认:false
  • decorators: Array<Decorator>(默认值:null,从构建器函数中排除)
  • returnTypeTypeAnnotation | TSTypeAnnotation | Noop(默认:null,从构建器函数中排除)
  • typeParametersTypeParameterDeclaration | TSTypeParameterDeclaration | Noop(默认:null,从构建器函数中排除)

别名:StandardizedUserWhitespacableFunctionScopableBlockParentFunctionParentMethodObjectMember


对象模式

JavaScript
t.objectPattern(properties);

另请参阅t.isObjectPattern(node, opts)t.assertObjectPattern(node, opts)

AST 节点ObjectPattern形状

  • propertiesArray<RestElement | ObjectProperty>(必需)
  • decorators: Array<Decorator>(默认值:null,从构建器函数中排除)
  • optional: boolean(默认值:null,从构建器函数中排除)
  • typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop(默认值:null,从构建器函数中排除)

别名:StandardizedPatternPatternLikeLVal


对象属性

JavaScript
t.objectProperty(key, value, computed, shorthand, decorators);

另请参阅t.isObjectProperty(node, opts)t.assertObjectProperty(node, opts)

AST 节点ObjectProperty形状

  • key: 如果计算则为 Expression,否则为 Identifier | Literal(必需)
  • valueExpression | PatternLike(必需)
  • computed: boolean(默认值:false
  • shorthandboolean(默认:false
  • decorators: Array<Decorator>(默认值:null

别名:StandardizedUserWhitespacablePropertyObjectMember


对象类型注释

JavaScript
t.objectTypeAnnotation(properties, indexers, callProperties, internalSlots, exact);

另请参阅t.isObjectTypeAnnotation(node, opts)t.assertObjectTypeAnnotation(node, opts)

AST 节点ObjectTypeAnnotation形状

  • propertiesArray<ObjectTypeProperty | ObjectTypeSpreadProperty>(必需)
  • indexersArray<ObjectTypeIndexer>(默认:[]
  • callPropertiesArray<ObjectTypeCallProperty>(默认:[]
  • internalSlotsArray<ObjectTypeInternalSlot>(默认:[]
  • exactboolean(默认:false
  • inexactboolean(默认:null,从生成器函数中排除)

别名:FlowFlowType


对象类型调用属性

JavaScript
t.objectTypeCallProperty(value);

另请参阅t.isObjectTypeCallProperty(node, opts)t.assertObjectTypeCallProperty(node, opts)

AST 节点ObjectTypeCallProperty形状

  • valueFlowType(必需)
  • staticboolean(必需)

别名:FlowUserWhitespacable


对象类型索引器

JavaScript
t.objectTypeIndexer(id, key, value, variance);

另请参阅t.isObjectTypeIndexer(node, opts)t.assertObjectTypeIndexer(node, opts)

AST 节点ObjectTypeIndexer形状

  • id: Identifier(默认值:null
  • keyFlowType(必需)
  • valueFlowType(必需)
  • varianceVariance(默认:null
  • staticboolean(必需)

别名:FlowUserWhitespacable


对象类型内部槽

JavaScript
t.objectTypeInternalSlot(id, value, optional, static, method);

另请参阅t.isObjectTypeInternalSlot(node, opts)t.assertObjectTypeInternalSlot(node, opts)

AST 节点ObjectTypeInternalSlot形状

  • id: Identifier(必需)
  • valueFlowType(必需)
  • optionalboolean(必需)
  • staticboolean(必需)
  • method: boolean(必需)

别名:FlowUserWhitespacable


objectTypeProperty

JavaScript
t.objectTypeProperty(key, value, variance);

另请参阅 t.isObjectTypeProperty(node, opts)t.assertObjectTypeProperty(node, opts)

AST 节点 ObjectTypeProperty 形状

  • key: Identifier | StringLiteral(必需)
  • valueFlowType(必需)
  • varianceVariance(默认:null
  • kind: "init" | "get" | "set"(必需)
  • method: boolean(必需)
  • optionalboolean(必需)
  • proto: boolean(必需)
  • staticboolean(必需)

别名:FlowUserWhitespacable


objectTypeSpreadProperty

JavaScript
t.objectTypeSpreadProperty(argument);

另请参阅 t.isObjectTypeSpreadProperty(node, opts)t.assertObjectTypeSpreadProperty(node, opts)

AST 节点 ObjectTypeSpreadProperty 形状

  • argument: FlowType(必需)

别名:FlowUserWhitespacable


opaqueType

JavaScript
t.opaqueType(id, typeParameters, supertype, impltype);

另请参阅 t.isOpaqueType(node, opts)t.assertOpaqueType(node, opts)

AST 节点 OpaqueType 形状

  • id: Identifier(必需)
  • typeParametersTypeParameterDeclaration(默认:null
  • supertype: FlowType(默认值:null
  • impltype: FlowType(必需)

别名:FlowFlowDeclarationStatementDeclaration


optionalCallExpression

JavaScript
t.optionalCallExpression(callee, arguments, optional);

另请参阅 t.isOptionalCallExpression(node, opts)t.assertOptionalCallExpression(node, opts)

AST 节点 OptionalCallExpression 形状

  • callee: Expression(必需)
  • arguments: Array<Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder>(必需)
  • optionalboolean(必需)
  • typeArguments: TypeParameterInstantiation(默认值:null,从生成器函数中排除)
  • typeParameters: TSTypeParameterInstantiation(默认值:null,从生成器函数中排除)

别名:StandardizedExpression


optionalIndexedAccessType

JavaScript
t.optionalIndexedAccessType(objectType, indexType);

另请参阅 t.isOptionalIndexedAccessType(node, opts)t.assertOptionalIndexedAccessType(node, opts)

AST 节点 OptionalIndexedAccessType 形状

  • objectType: FlowType(必需)
  • indexType: FlowType(必需)
  • optionalboolean(必需)

别名:FlowFlowType


optionalMemberExpression

JavaScript
t.optionalMemberExpression(object, property, computed, optional);

另请参阅 t.isOptionalMemberExpression(node, opts)t.assertOptionalMemberExpression(node, opts)

AST 节点 OptionalMemberExpression 形状

  • object: Expression(必需)
  • property: Expression | Identifier(必需)
  • computed: boolean(默认值:false
  • optionalboolean(必需)

别名:StandardizedExpression


parenthesizedExpression

JavaScript
t.parenthesizedExpression(expression);

另请参阅 t.isParenthesizedExpression(node, opts)t.assertParenthesizedExpression(node, opts)

AST 节点 ParenthesizedExpression 形状

  • expressionExpression(必需)

别名:StandardizedExpressionExpressionWrapper


pipelineBareFunction

JavaScript
t.pipelineBareFunction(callee);

另请参阅 t.isPipelineBareFunction(node, opts)t.assertPipelineBareFunction(node, opts)

AST 节点 PipelineBareFunction 形状

  • callee: Expression(必需)

别名:Expression


pipelinePrimaryTopicReference

JavaScript
t.pipelinePrimaryTopicReference();

另请参阅 t.isPipelinePrimaryTopicReference(node, opts)t.assertPipelinePrimaryTopicReference(node, opts)

别名:Expression


pipelineTopicExpression

JavaScript
t.pipelineTopicExpression(expression);

另请参阅 t.isPipelineTopicExpression(node, opts)t.assertPipelineTopicExpression(node, opts)

AST 节点 PipelineTopicExpression 形状

  • expressionExpression(必需)

别名:Expression


placeholder

JavaScript
t.placeholder(expectedNode, name);

另请参阅 t.isPlaceholder(node, opts)t.assertPlaceholder(node, opts)

AST 节点 Placeholder 形状

  • expectedNode: "标识符" | "字符串字面量" | "表达式" | "语句" | "声明" | "块语句" | "类主体" | "模式" (必需)
  • name: 标识符 (必需)

别名:Miscellaneous


privateName

JavaScript
t.privateName(id);

另请参阅 t.isPrivateName(node, opts)t.assertPrivateName(node, opts)

AST 节点 PrivateName 形状

  • id: Identifier(必需)

别名:StandardizedPrivate


program

JavaScript
t.program(body, directives, sourceType, interpreter);

另请参阅 t.isProgram(node, opts)t.assertProgram(node, opts)

AST 节点 Program 形状

  • body: Array<Statement>(必需)
  • directives: Array<Directive>(默认值:[]
  • sourceType: "script" | "module" (默认:'script')
  • interpreter: InterpreterDirective (默认:null)

别名:StandardizedScopableBlockParentBlock


qualifiedTypeIdentifier

JavaScript
t.qualifiedTypeIdentifier(id, qualification);

另请参阅 t.isQualifiedTypeIdentifier(node, opts)t.assertQualifiedTypeIdentifier(node, opts)

AST 节点 QualifiedTypeIdentifier 形状

  • id: Identifier(必需)
  • qualification: 标识符 | QualifiedTypeIdentifier (必需)

别名:Flow


recordExpression

JavaScript
t.recordExpression(properties);

另请参阅 t.isRecordExpression(node, opts)t.assertRecordExpression(node, opts)

AST 节点 RecordExpression 形状

  • properties: Array<ObjectProperty | SpreadElement> (必需)

别名:Expression


regExpLiteral

JavaScript
t.regExpLiteral(pattern, flags);

另请参阅 t.isRegExpLiteral(node, opts)t.assertRegExpLiteral(node, opts)

AST 节点 RegExpLiteral 形状

  • pattern: string (必需)
  • flags: string (默认:'')

别名:StandardizedExpressionPureishLiteral


restElement

JavaScript
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,从构建器函数中排除)

别名:StandardizedLValPatternLike


returnStatement

JavaScript
t.returnStatement(argument);

另请参阅 t.isReturnStatement(node, opts)t.assertReturnStatement(node, opts)

AST 节点 ReturnStatement 形状

  • argument: Expression (默认:null)

别名:StandardizedStatementTerminatorlessCompletionStatement


sequenceExpression

JavaScript
t.sequenceExpression(expressions);

另请参阅 t.isSequenceExpression(node, opts)t.assertSequenceExpression(node, opts)

AST 节点 SequenceExpression 形状

  • expressions: Array<Expression> (必需)

别名:StandardizedExpression


spreadElement

JavaScript
t.spreadElement(argument);

另请参阅 t.isSpreadElement(node, opts)t.assertSpreadElement(node, opts)

AST 节点 SpreadElement 形状

  • argumentExpression(必需)

别名:StandardizedUnaryLike


staticBlock

JavaScript
t.staticBlock(body);

另请参阅 t.isStaticBlock(node, opts)t.assertStaticBlock(node, opts)

AST 节点 StaticBlock 形状

  • body: Array<Statement>(必需)

别名:StandardizedScopableBlockParentFunctionParent


stringLiteral

JavaScript
t.stringLiteral(value);

另请参阅 t.isStringLiteral(node, opts)t.assertStringLiteral(node, opts)

AST 节点 StringLiteral 形状

  • valuestring(必需)

别名:StandardizedExpressionPureishLiteralImmutable


stringLiteralTypeAnnotation

JavaScript
t.stringLiteralTypeAnnotation(value);

另请参阅 t.isStringLiteralTypeAnnotation(node, opts)t.assertStringLiteralTypeAnnotation(node, opts)

AST 节点 StringLiteralTypeAnnotation 形状

  • valuestring(必需)

别名:FlowFlowType


stringTypeAnnotation

JavaScript
t.stringTypeAnnotation();

另请参阅 t.isStringTypeAnnotation(node, opts)t.assertStringTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


super

JavaScript
t.super();

另请参阅 t.isSuper(node, opts)t.assertSuper(node, opts)

别名:StandardizedExpression


switchCase

JavaScript
t.switchCase(test, consequent);

另请参阅 t.isSwitchCase(node, opts)t.assertSwitchCase(node, opts)

AST 节点 SwitchCase 形状

  • test: Expression(默认值:null
  • consequent: Array<Statement>(必需)

别名:Standardized


switchStatement

JavaScript
t.switchStatement(discriminant, cases);

另请参阅 t.isSwitchStatement(node, opts)t.assertSwitchStatement(node, opts)

AST 节点 SwitchStatement 形状

  • discriminant: Expression(必需)
  • cases: Array<SwitchCase>(必需)

别名:StandardizedStatementBlockParentScopable


symbolTypeAnnotation

JavaScript
t.symbolTypeAnnotation();

另请参阅 t.isSymbolTypeAnnotation(node, opts)t.assertSymbolTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


tsAnyKeyword

JavaScript
t.tsAnyKeyword();

另请参阅 t.isTSAnyKeyword(node, opts)t.assertTSAnyKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsArrayType

JavaScript
t.tsArrayType(elementType);

另请参阅 t.isTSArrayType(node, opts)t.assertTSArrayType(node, opts)

AST 节点 TSArrayType 形状

  • elementType: TSType(必需)

别名:TypeScriptTSType


tsAsExpression

JavaScript
t.tsAsExpression(expression, typeAnnotation);

另请参阅 t.isTSAsExpression(node, opts)t.assertTSAsExpression(node, opts)

AST 节点 TSAsExpression 形状

  • expressionExpression(必需)
  • typeAnnotation: TSType(必需)

别名:TypeScriptExpressionLValPatternLike


tsBigIntKeyword

JavaScript
t.tsBigIntKeyword();

另请参阅 t.isTSBigIntKeyword(node, opts)t.assertTSBigIntKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsBooleanKeyword

JavaScript
t.tsBooleanKeyword();

另请参见 t.isTSBooleanKeyword(node, opts)t.assertTSBooleanKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsCallSignatureDeclaration

JavaScript
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

别名:TypeScriptTSTypeElement


tsConditionalType

JavaScript
t.tsConditionalType(checkType, extendsType, trueType, falseType);

另请参见 t.isTSConditionalType(node, opts)t.assertTSConditionalType(node, opts)

AST 节点 TSConditionalType 形状

  • checkType: TSType(必需)
  • extendsType: TSType(必需)
  • trueType: TSType(必需)
  • falseType: TSType(必需)

别名:TypeScriptTSType


tsConstructSignatureDeclaration

JavaScript
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

别名:TypeScriptTSTypeElement


tsConstructorType

JavaScript
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,从构建器函数中排除)

别名:TypeScriptTSType


tsDeclareFunction

JavaScript
t.tsDeclareFunction(id, typeParameters, params, returnType);

另请参见 t.isTSDeclareFunction(node, opts)t.assertTSDeclareFunction(node, opts)

AST 节点 TSDeclareFunction 形状

  • id: Identifier(默认值:null
  • typeParameters: TSTypeParameterDeclaration | Noop(默认值:null
  • paramsArray<Identifier | Pattern | RestElement>(必需)
  • returnType: TSTypeAnnotation | Noop(默认值:null
  • asyncboolean(默认:false,从构建器函数中排除)
  • declare: boolean(默认值:null,从构建器函数中排除)
  • generatorboolean(默认:false,从构建器函数中排除)

别名:TypeScriptStatementDeclaration


tsDeclareMethod

JavaScript
t.tsDeclareMethod(decorators, key, typeParameters, params, returnType);

另请参见 t.isTSDeclareMethod(node, opts)t.assertTSDeclareMethod(node, opts)

AST 节点 TSDeclareMethod 形状

  • decorators: Array<Decorator>(默认值:null
  • keyIdentifier | 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,从构建器函数中排除)
  • asyncboolean(默认:false,从构建器函数中排除)
  • computed: boolean(默认值:false,从构建器函数中排除)
  • generatorboolean(默认:false,从构建器函数中排除)
  • kind: "get" | "set" | "method" | "constructor"(默认值:'method',从构建器函数中排除)
  • optional: boolean(默认值:null,从构建器函数中排除)
  • override: boolean(默认值:false,从构建器函数中排除)
  • static: boolean(默认值:false,从构建器函数中排除)

别名:TypeScript


tsEnumDeclaration

JavaScript
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,从构建器函数中排除)

别名:TypeScriptStatementDeclaration


tsEnumMember

JavaScript
t.tsEnumMember(id, initializer);

另请参见 t.isTSEnumMember(node, opts)t.assertTSEnumMember(node, opts)

AST 节点 TSEnumMember 形状

  • id: Identifier | StringLiteral(必需)
  • initializer: Expression(默认值:null

别名:TypeScript


tsExportAssignment

JavaScript
t.tsExportAssignment(expression);

另请参见 t.isTSExportAssignment(node, opts)t.assertTSExportAssignment(node, opts)

AST 节点 TSExportAssignment 形状

  • expressionExpression(必需)

别名:TypeScriptStatement


tsExpressionWithTypeArguments

JavaScript
t.tsExpressionWithTypeArguments(expression, typeParameters);

另请参阅 t.isTSExpressionWithTypeArguments(node, opts)t.assertTSExpressionWithTypeArguments(node, opts)

AST 节点 TSExpressionWithTypeArguments 形状

  • expression: TSEntityName(必需)
  • typeParameters: TSTypeParameterInstantiation(默认值:null

别名:TypeScriptTSType


tsExternalModuleReference

JavaScript
t.tsExternalModuleReference(expression);

另请参阅 t.isTSExternalModuleReference(node, opts)t.assertTSExternalModuleReference(node, opts)

AST 节点 TSExternalModuleReference 形状

  • expression: StringLiteral(必需)

别名:TypeScript


tsFunctionType

JavaScript
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

别名:TypeScriptTSType


tsImportEqualsDeclaration

JavaScript
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(必需)

别名:TypeScriptStatement


tsImportType

JavaScript
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,从构建器函数中排除)

别名:TypeScriptTSType


tsIndexSignature

JavaScript
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,从构建器函数中排除)

别名:TypeScriptTSTypeElement


tsIndexedAccessType

JavaScript
t.tsIndexedAccessType(objectType, indexType);

另请参阅 t.isTSIndexedAccessType(node, opts)t.assertTSIndexedAccessType(node, opts)

AST 节点 TSIndexedAccessType 形状

  • objectType: TSType(必需)
  • indexType: TSType(必需)

别名:TypeScriptTSType


tsInferType

JavaScript
t.tsInferType(typeParameter);

另请参阅 t.isTSInferType(node, opts)t.assertTSInferType(node, opts)

AST 节点 TSInferType 形状

  • typeParameter: TSTypeParameter(必需)

别名:TypeScriptTSType


tsInstantiationExpression

JavaScript
t.tsInstantiationExpression(expression, typeParameters);

另请参阅 t.isTSInstantiationExpression(node, opts)t.assertTSInstantiationExpression(node, opts)

AST 节点 TSInstantiationExpression 形状

  • expressionExpression(必需)
  • typeParameters: TSTypeParameterInstantiation(默认值:null

别名:TypeScriptExpression


tsInterfaceBody

JavaScript
t.tsInterfaceBody(body);

另请参见 t.isTSInterfaceBody(node, opts)t.assertTSInterfaceBody(node, opts)

AST 节点 TSInterfaceBody 形状

  • body: Array<TSTypeElement>(必需)

别名:TypeScript


tsInterfaceDeclaration

JavaScript
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,从构建器函数中排除)

别名:TypeScriptStatementDeclaration


tsIntersectionType

JavaScript
t.tsIntersectionType(types);

另请参见 t.isTSIntersectionType(node, opts)t.assertTSIntersectionType(node, opts)

AST 节点 TSIntersectionType 形状

  • types: Array<TSType>(必需)

别名:TypeScriptTSType


tsIntrinsicKeyword

JavaScript
t.tsIntrinsicKeyword();

另请参见 t.isTSIntrinsicKeyword(node, opts)t.assertTSIntrinsicKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsLiteralType

JavaScript
t.tsLiteralType(literal);

另请参见 t.isTSLiteralType(node, opts)t.assertTSLiteralType(node, opts)

AST 节点 TSLiteralType 形状

  • literal: NumericLiteral | StringLiteral | BooleanLiteral | BigIntLiteral | TemplateLiteral | UnaryExpression(必需)

别名:TypeScriptTSTypeTSBaseType


tsMappedType

JavaScript
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,从构建器函数中排除)

别名:TypeScriptTSType


tsMethodSignature

JavaScript
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,从构建器函数中排除)

别名:TypeScriptTSTypeElement


tsModuleBlock

JavaScript
t.tsModuleBlock(body);

另请参见 t.isTSModuleBlock(node, opts)t.assertTSModuleBlock(node, opts)

AST 节点 TSModuleBlock 形状

  • body: Array<Statement>(必需)

别名:TypeScriptScopableBlockBlockParentFunctionParent


tsModuleDeclaration

JavaScript
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,从构建器函数中排除)

别名:TypeScriptStatementDeclaration


tsNamedTupleMember

JavaScript
t.tsNamedTupleMember(label, elementType, optional);

另请参见 t.isTSNamedTupleMember(node, opts)t.assertTSNamedTupleMember(node, opts)

AST 节点 TSNamedTupleMember 形状

  • label: Identifier(必需)
  • elementType: TSType(必需)
  • 可选布尔值(默认:false

别名:TypeScript


tsNamespaceExportDeclaration

JavaScript
t.tsNamespaceExportDeclaration(id);

另请参阅 t.isTSNamespaceExportDeclaration(node, opts)t.assertTSNamespaceExportDeclaration(node, opts)

AST 节点 TSNamespaceExportDeclaration 形状

  • id: Identifier(必需)

别名:TypeScriptStatement


tsNeverKeyword

JavaScript
t.tsNeverKeyword();

另请参阅 t.isTSNeverKeyword(node, opts)t.assertTSNeverKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsNonNullExpression

JavaScript
t.tsNonNullExpression(expression);

另请参阅 t.isTSNonNullExpression(node, opts)t.assertTSNonNullExpression(node, opts)

AST 节点 TSNonNullExpression 形状

  • expressionExpression(必需)

别名:TypeScriptExpressionLValPatternLike


tsNullKeyword

JavaScript
t.tsNullKeyword();

另请参阅 t.isTSNullKeyword(node, opts)t.assertTSNullKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsNumberKeyword

JavaScript
t.tsNumberKeyword();

另请参阅 t.isTSNumberKeyword(node, opts)t.assertTSNumberKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsObjectKeyword

JavaScript
t.tsObjectKeyword();

另请参阅 t.isTSObjectKeyword(node, opts)t.assertTSObjectKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsOptionalType

JavaScript
t.tsOptionalType(typeAnnotation);

另请参阅 t.isTSOptionalType(node, opts)t.assertTSOptionalType(node, opts)

AST 节点 TSOptionalType 形状

  • typeAnnotation: TSType(必需)

别名:TypeScriptTSType


tsParameterProperty

JavaScript
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,从构建器函数中排除)

别名:TypeScriptLVal


tsParenthesizedType

JavaScript
t.tsParenthesizedType(typeAnnotation);

另请参阅 t.isTSParenthesizedType(node, opts)t.assertTSParenthesizedType(node, opts)

AST 节点 TSParenthesizedType 形状

  • typeAnnotation: TSType(必需)

别名:TypeScriptTSType


tsPropertySignature

JavaScript
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,从构建器函数中排除)

别名:TypeScriptTSTypeElement


tsQualifiedName

JavaScript
t.tsQualifiedName(left, right);

另请参阅 t.isTSQualifiedName(node, opts)t.assertTSQualifiedName(node, opts)

AST 节点 TSQualifiedName 形状

  • leftTSEntityName(必需)
  • right标识符(必需)

别名:TypeScriptTSEntityName


tsRestType

JavaScript
t.tsRestType(typeAnnotation);

另请参阅 t.isTSRestType(node, opts)t.assertTSRestType(node, opts)

AST 节点 TSRestType 形状

  • typeAnnotation: TSType(必需)

别名:TypeScriptTSType


tsSatisfiesExpression

JavaScript
t.tsSatisfiesExpression(expression, typeAnnotation);
历史记录
版本更改
v7.20.0已引入

另请参见t.isTSSatisfiesExpression(node, opts)t.assertTSSatisfiesExpression(node, opts)

AST 节点 TSSatisfiesExpression 形状

  • expressionExpression(必需)
  • typeAnnotation: TSType(必需)

别名:TypeScriptExpressionLValPatternLike


tsStringKeyword

JavaScript
t.tsStringKeyword();

另请参见t.isTSStringKeyword(node, opts)t.assertTSStringKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsSymbolKeyword

JavaScript
t.tsSymbolKeyword();

另请参见t.isTSSymbolKeyword(node, opts)t.assertTSSymbolKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsThisType

JavaScript
t.tsThisType();

另请参见t.isTSThisType(node, opts)t.assertTSThisType(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsTupleType

JavaScript
t.tsTupleType(elementTypes);

另请参见t.isTSTupleType(node, opts)t.assertTSTupleType(node, opts)

AST 节点 TSTupleType 形状

  • elementTypes: Array<TSType | TSNamedTupleMember>(必需)

别名:TypeScriptTSType


tsTypeAliasDeclaration

JavaScript
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,从构建器函数中排除)

别名:TypeScriptStatementDeclaration


tsTypeAnnotation

JavaScript
t.tsTypeAnnotation(typeAnnotation);

另请参见t.isTSTypeAnnotation(node, opts)t.assertTSTypeAnnotation(node, opts)

AST 节点 TSTypeAnnotation 形状

  • typeAnnotation: TSType(必需)

别名:TypeScript


tsTypeAssertion

JavaScript
t.tsTypeAssertion(typeAnnotation, expression);

另请参见t.isTSTypeAssertion(node, opts)t.assertTSTypeAssertion(node, opts)

AST 节点 TSTypeAssertion 形状

  • typeAnnotation: TSType(必需)
  • expressionExpression(必需)

别名:TypeScriptExpressionLValPatternLike


tsTypeLiteral

JavaScript
t.tsTypeLiteral(members);

另请参见t.isTSTypeLiteral(node, opts)t.assertTSTypeLiteral(node, opts)

AST 节点 TSTypeLiteral 形状

  • members: Array<TSTypeElement>(必需)

别名:TypeScriptTSType


tsTypeOperator

JavaScript
t.tsTypeOperator(typeAnnotation);

另请参见t.isTSTypeOperator(node, opts)t.assertTSTypeOperator(node, opts)

AST 节点 TSTypeOperator 形状

  • typeAnnotation: TSType(必需)
  • operatorstring(必需)

别名:TypeScriptTSType


tsTypeParameter

JavaScript
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

JavaScript
t.tsTypeParameterDeclaration(params);

另请参见t.isTSTypeParameterDeclaration(node, opts)t.assertTSTypeParameterDeclaration(node, opts)

AST 节点 TSTypeParameterDeclaration 形状

  • params: Array<TSTypeParameter>(必需)

别名:TypeScript


tsTypeParameterInstantiation

JavaScript
t.tsTypeParameterInstantiation(params);

另请参阅 t.isTSTypeParameterInstantiation(node, opts)t.assertTSTypeParameterInstantiation(node, opts)

AST 节点 TSTypeParameterInstantiation 形状

  • params: Array<TSType>(必需)

别名:TypeScript


tsTypePredicate

JavaScript
t.tsTypePredicate(parameterName, typeAnnotation, asserts);

另请参阅 t.isTSTypePredicate(node, opts)t.assertTSTypePredicate(node, opts)

AST 节点 TSTypePredicate 形状

  • parameterName: Identifier | TSThisType(必需)
  • typeAnnotation: TSTypeAnnotation(默认值:null
  • asserts: boolean(默认值:null

别名:TypeScriptTSType


tsTypeQuery

JavaScript
t.tsTypeQuery(exprName, typeParameters);

另请参阅 t.isTSTypeQuery(node, opts)t.assertTSTypeQuery(node, opts)

AST 节点 TSTypeQuery 形状

  • exprName: TSEntityName | TSImportType(必需)
  • typeParameters: TSTypeParameterInstantiation(默认值:null

别名:TypeScriptTSType


tsTypeReference

JavaScript
t.tsTypeReference(typeName, typeParameters);

另请参阅 t.isTSTypeReference(node, opts)t.assertTSTypeReference(node, opts)

AST 节点 TSTypeReference 形状

  • typeName: TSEntityName(必需)
  • typeParameters: TSTypeParameterInstantiation(默认值:null

别名:TypeScriptTSType


tsUndefinedKeyword

JavaScript
t.tsUndefinedKeyword();

另请参阅 t.isTSUndefinedKeyword(node, opts)t.assertTSUndefinedKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsUnionType

JavaScript
t.tsUnionType(types);

另请参阅 t.isTSUnionType(node, opts)t.assertTSUnionType(node, opts)

AST 节点 TSUnionType 形状

  • types: Array<TSType>(必需)

别名:TypeScriptTSType


tsUnknownKeyword

JavaScript
t.tsUnknownKeyword();

另请参阅 t.isTSUnknownKeyword(node, opts)t.assertTSUnknownKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


tsVoidKeyword

JavaScript
t.tsVoidKeyword();

另请参阅 t.isTSVoidKeyword(node, opts)t.assertTSVoidKeyword(node, opts)

别名:TypeScriptTSTypeTSBaseType


taggedTemplateExpression

JavaScript
t.taggedTemplateExpression(tag, quasi);

另请参阅 t.isTaggedTemplateExpression(node, opts)t.assertTaggedTemplateExpression(node, opts)

AST 节点 TaggedTemplateExpression 形状

  • tag: Expression(必需)
  • quasi: TemplateLiteral(必需)
  • typeParameters: TypeParameterInstantiation | TSTypeParameterInstantiation(默认值:null,从构建器函数中排除)

别名:StandardizedExpression


templateElement

JavaScript
t.templateElement(value, tail);

另请参阅 t.isTemplateElement(node, opts)t.assertTemplateElement(node, opts)

AST 节点 TemplateElement 形状

  • value: { raw: string, cooked?: string }(必需)
  • tail: boolean(默认值:false

别名:Standardized


templateLiteral

JavaScript
t.templateLiteral(quasis, expressions);

另请参阅 t.isTemplateLiteral(node, opts)t.assertTemplateLiteral(node, opts)

AST 节点 TemplateLiteral 形状

  • quasis: Array<TemplateElement>(必需)
  • expressions: Array<Expression | TSType>(必需)

别名:StandardizedExpressionLiteral


thisExpression

JavaScript
t.thisExpression();

另请参阅 t.isThisExpression(node, opts)t.assertThisExpression(node, opts)

别名:StandardizedExpression


thisTypeAnnotation

JavaScript
t.thisTypeAnnotation();

另请参阅 t.isThisTypeAnnotation(node, opts)t.assertThisTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


throwStatement

JavaScript
t.throwStatement(argument);

另请参阅 t.isThrowStatement(node, opts)t.assertThrowStatement(node, opts)

AST 节点 ThrowStatement 形状

  • argumentExpression(必需)

别名:StandardizedStatementTerminatorlessCompletionStatement


topicReference

JavaScript
t.topicReference();

另请参阅 t.isTopicReference(node, opts)t.assertTopicReference(node, opts)

别名:Expression


tryStatement

JavaScript
t.tryStatement(block, handler, finalizer);

另请参阅 t.isTryStatement(node, opts)t.assertTryStatement(node, opts)

AST 节点 TryStatement 形状

  • block: BlockStatement(必需)
  • handler: CatchClause(默认值:null
  • finalizer: BlockStatement(默认值:null

别名:StandardizedStatement


tupleExpression

JavaScript
t.tupleExpression(elements);

另请参阅 t.isTupleExpression(node, opts)t.assertTupleExpression(node, opts)

AST 节点 TupleExpression 形状

  • elements: Array<Expression | SpreadElement>(默认值:[]

别名:Expression


tupleTypeAnnotation

JavaScript
t.tupleTypeAnnotation(types);

另请参阅 t.isTupleTypeAnnotation(node, opts)t.assertTupleTypeAnnotation(node, opts)

AST 节点 TupleTypeAnnotation 形状

  • types: Array<FlowType>(必需)

别名:FlowFlowType


typeAlias

JavaScript
t.typeAlias(id, typeParameters, right);

另请参阅 t.isTypeAlias(node, opts)t.assertTypeAlias(node, opts)

AST 节点 TypeAlias 形状

  • id: Identifier(必需)
  • typeParametersTypeParameterDeclaration(默认:null
  • right: FlowType(必需)

别名:FlowFlowDeclarationStatementDeclaration


typeAnnotation

JavaScript
t.typeAnnotation(typeAnnotation);

另请参阅 t.isTypeAnnotation(node, opts)t.assertTypeAnnotation(node, opts)

AST 节点 TypeAnnotation 形状

  • typeAnnotation: FlowType(必需)

别名:Flow


typeCastExpression

JavaScript
t.typeCastExpression(expression, typeAnnotation);

另请参阅 t.isTypeCastExpression(node, opts)t.assertTypeCastExpression(node, opts)

AST 节点 TypeCastExpression 形状

  • expressionExpression(必需)
  • typeAnnotation: TypeAnnotation(必需)

别名:FlowExpressionWrapperExpression


typeParameter

JavaScript
t.typeParameter(bound, default, variance);

另请参阅 t.isTypeParameter(node, opts)t.assertTypeParameter(node, opts)

AST 节点 TypeParameter 形状

  • bound: TypeAnnotation(默认值:null
  • default: FlowType(默认值:null
  • varianceVariance(默认:null
  • name: string(必需)

别名:Flow


typeParameterDeclaration

JavaScript
t.typeParameterDeclaration(params);

另请参阅 t.isTypeParameterDeclaration(node, opts)t.assertTypeParameterDeclaration(node, opts)

AST 节点 TypeParameterDeclaration 形状

  • params: Array<TypeParameter>(必需)

别名:Flow


typeParameterInstantiation

JavaScript
t.typeParameterInstantiation(params);

另请参阅 t.isTypeParameterInstantiation(node, opts)t.assertTypeParameterInstantiation(node, opts)

AST 节点 TypeParameterInstantiation 形状

  • params: Array<FlowType>(必需)

别名:Flow


typeofTypeAnnotation

JavaScript
t.typeofTypeAnnotation(argument);

另请参阅 t.isTypeofTypeAnnotation(node, opts)t.assertTypeofTypeAnnotation(node, opts)

AST 节点 TypeofTypeAnnotation 形状

  • argument: FlowType(必需)

别名:FlowFlowType


unaryExpression

JavaScript
t.unaryExpression(operator, argument, prefix);

另请参阅 t.isUnaryExpression(node, opts)t.assertUnaryExpression(node, opts)

AST 节点 UnaryExpression 形状

  • operator: "void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof"(必需)
  • argumentExpression(必需)
  • prefix: boolean(默认值:true

别名:StandardizedUnaryLikeExpression


unionTypeAnnotation

JavaScript
t.unionTypeAnnotation(types);

另请参阅 t.isUnionTypeAnnotation(node, opts)t.assertUnionTypeAnnotation(node, opts)

AST 节点 UnionTypeAnnotation 形状

  • types: Array<FlowType>(必需)

别名:FlowFlowType


updateExpression

JavaScript
t.updateExpression(operator, argument, prefix);

另请参阅 t.isUpdateExpression(node, opts)t.assertUpdateExpression(node, opts)

AST 节点 UpdateExpression 形状

  • operator: "++" | "--"(必需)
  • argumentExpression(必需)
  • prefix: boolean(默认值:false

别名:StandardizedExpression


v8IntrinsicIdentifier

JavaScript
t.v8IntrinsicIdentifier(name);

另请参阅 t.isV8IntrinsicIdentifier(node, opts)t.assertV8IntrinsicIdentifier(node, opts)

AST 节点 V8IntrinsicIdentifier 形状

  • name: string(必需)

别名:Miscellaneous


variableDeclaration

JavaScript
t.variableDeclaration(kind, declarations);
历史记录
版本更改
v7.20.0kind 可以是“using”。

另请参阅 t.isVariableDeclaration(node, opts)t.assertVariableDeclaration(node, opts)

AST 节点 VariableDeclaration 形状

  • kind: "var" | "let" | "const" | "using" | "await using"(必需)
  • declarations: Array<VariableDeclarator>(必需)
  • declare: boolean(默认值:null,从构建器函数中排除)

别名:StandardizedStatementDeclaration


variableDeclarator

JavaScript
t.variableDeclarator(id, init);

另请参阅 t.isVariableDeclarator(node, opts)t.assertVariableDeclarator(node, opts)

AST 节点 VariableDeclarator 形状

  • id: LVal(必需)
  • init: Expression(默认值:null
  • definite: boolean(默认值:null,从构建器函数中排除)

别名:Standardized


variance

JavaScript
t.variance(kind);

另请参阅 t.isVariance(node, opts)t.assertVariance(node, opts)

AST 节点 Variance 形状

  • kind: "minus" | "plus"(必需)

别名:Flow


voidTypeAnnotation

JavaScript
t.voidTypeAnnotation();

另请参阅 t.isVoidTypeAnnotation(node, opts)t.assertVoidTypeAnnotation(node, opts)

别名:FlowFlowTypeFlowBaseAnnotation


whileStatement

JavaScript
t.whileStatement(test, body);

另请参阅 t.isWhileStatement(node, opts)t.assertWhileStatement(node, opts)

AST 节点 WhileStatement 形状

  • testExpression(必需)
  • bodyStatement(必需)

别名:StandardizedStatementBlockParentLoopWhileScopable


withStatement

JavaScript
t.withStatement(object, body);

另请参阅 t.isWithStatement(node, opts)t.assertWithStatement(node, opts)

AST 节点 WithStatement 形状

  • object: Expression(必需)
  • bodyStatement(必需)

别名:StandardizedStatement


yieldExpression

JavaScript
t.yieldExpression(argument, delegate);

另请参阅 t.isYieldExpression(node, opts)t.assertYieldExpression(node, opts)

AST 节点 YieldExpression 形状

  • argument: Expression (默认:null)
  • delegate: boolean(默认值:false

别名:StandardizedExpressionTerminatorless


别名

Accessor

已弃用。将在 Babel 8 中移除。

JavaScript
t.isAccessor(node);

涵盖的节点

Binary

BinaryExpression 和 LogicalExpression 的覆盖,它们共享相同的 AST 形状。

JavaScript
t.isBinary(node);

涵盖的节点

Block

已弃用。将在 Babel 8 中移除。

JavaScript
t.isBlock(node);

涵盖的节点

BlockParent

AST 节点的覆盖,这些节点以新的 LexicalEnvironment 开始执行上下文。换句话说,它们定义了 letconst 声明的范围。

JavaScript
t.isBlockParent(node);

涵盖的节点

ClassExpression 和 ClassDeclaration 的一个覆盖,它们共享相同的 AST 形状。

JavaScript
t.isClass(node);

涵盖的节点

完成语句

指示完成记录的语句。换句话说,它们定义了程序的控制流,例如何时应中断循环或操作引发严重错误。

JavaScript
t.isCompletionStatement(node);

涵盖的节点

条件

ConditionalExpression 和 IfStatement 的一个覆盖,它们共享相同的 AST 形状。

JavaScript
t.isConditional(node);

涵盖的节点

声明

任何声明的覆盖。

JavaScript
t.isDeclaration(node);

涵盖的节点

枚举主体

Flow 枚举主体的覆盖。

JavaScript
t.isEnumBody(node);

涵盖的节点

枚举成员

Flow 枚举成员的覆盖。

JavaScript
t.isEnumMember(node);

涵盖的节点

导出声明

任何导出声明的覆盖。

JavaScript
t.isExportDeclaration(node);

涵盖的节点

表达式

任何表达式的覆盖。

JavaScript
t.isExpression(node);

涵盖的节点

ExpressionWrapper

没有运行时语义的表达式的包装器。

JavaScript
t.isExpressionWrapper(node);

涵盖的节点

Flow

为 Flow 定义的 AST 节点的覆盖。

JavaScript
t.isFlow(node);

涵盖的节点

FlowBaseAnnotation

主要 Flow 型アノテーションのカバー。

JavaScript
t.isFlowBaseAnnotation(node);

涵盖的节点

FlowDeclaration

Flow 宣言のカバー。

JavaScript
t.isFlowDeclaration(node);

涵盖的节点

FlowPredicate

Flow 述語のカバー。

JavaScript
t.isFlowPredicate(node);

涵盖的节点

FlowType

Flow 型アノテーションのカバー。

JavaScript
t.isFlowType(node);

涵盖的节点

For

ForStatementForXStatement のカバー。

JavaScript
t.isFor(node);

涵盖的节点

ForXStatement

ForInStatements と ForOfStatements のカバー。

JavaScript
t.isForXStatement(node);

涵盖的节点

Function

関数と メソッド のカバー。bodyparams が必要です。注: FunctionFunctionParent とは異なります。たとえば、StaticBlockFunctionParent ですが Function ではありません。

JavaScript
t.isFunction(node);

涵盖的节点

FunctionParent

开始执行上下文的新VariableEnvironment的 AST 节点覆盖。换句话说,它们定义了var声明的范围。从 Babel 7 开始,FunctionParent 不再包含Program

JavaScript
t.isFunctionParent(node);

涵盖的节点

Immutable

不可变对象和 JSX 元素的覆盖。如果创建后无法定义其他属性,则对象是不可变的。

JavaScript
t.isImmutable(node);

涵盖的节点

ImportOrExportDeclaration

历史记录
版本更改
v7.21.0已引入

ImportDeclaration 和 ExportDeclaration 的覆盖。

JavaScript
t.isImportOrExportDeclaration(node);

涵盖的节点

JSX

JSX 定义的 AST 节点的覆盖。

JavaScript
t.isJSX(node);

涵盖的节点

LVal

赋值表达式和 ForXStatementleft中使用的左侧表达式覆盖。

JavaScript
t.isLVal(node);

涵盖的节点

Literal

Literal正则表达式 LiteralTemplate Literal 的覆盖。

JavaScript
t.isLiteral(node);

涵盖的节点

Loop

循环语句的覆盖。

JavaScript
t.isLoop(node);

涵盖的节点

Method

对象方法和类方法的覆盖。

JavaScript
t.isMethod(node);

涵盖的节点

Miscellaneous

有时对开发有用的非标准 AST 类型的覆盖。

JavaScript
t.isMiscellaneous(node);

涵盖的节点

ModuleDeclaration

历史记录
版本更改
v7.21.0已弃用
注意

已弃用,请改用ImportOrExportDeclaration。查看 PR #15266 以获取迁移说明。

JavaScript
t.isModuleDeclaration(node);

涵盖的节点

ModuleSpecifier

导入和导出说明符的覆盖。注意:它不是规范中定义的 ModuleSpecifier

JavaScript
t.isModuleSpecifier(node);

涵盖的节点

ObjectMember

对象字面量中 成员 的覆盖。

JavaScript
t.isObjectMember(node);

涵盖的节点

Pattern

除了标识符之外,BindingPattern 的覆盖。

JavaScript
t.isPattern(node);

涵盖的节点

PatternLike

BindingPattern 的一个封面

JavaScript
t.isPatternLike(node);

涵盖的节点

Private

私有类元素和私有标识符的一个封面。

JavaScript
t.isPrivate(node);

涵盖的节点

Property

对象属性和类属性的一个封面。

JavaScript
t.isProperty(node);

涵盖的节点

Pureish

没有副作用的 AST 节点的封面。换句话说,如果对它们进行多次评估,则没有可观察的行为变化。

JavaScript
t.isPureish(node);

涵盖的节点

Scopable

FunctionParent 和 BlockParent 的一个封面。

JavaScript
t.isScopable(node);

涵盖的节点

Standardized

属于官方 ECMAScript 规范一部分的 AST 节点的封面。

JavaScript
t.isStandardized(node);

涵盖的节点

Statement

任何 Statement 的一个封面。

JavaScript
t.isStatement(node);

涵盖的节点

TSBaseType

主要 TypeScript 类型注释的一个封面。

JavaScript
t.isTSBaseType(node);

涵盖的节点

TSEntityName

ts 实体的一个封面。

JavaScript
t.isTSEntityName(node);

涵盖的节点

TSType

TypeScript 类型注释的一个封面。

JavaScript
t.isTSType(node);

涵盖的节点

TSTypeElement

TypeScript 类型声明的一个封面。

JavaScript
t.isTSTypeElement(node);

涵盖的节点

Terminatorless

当在运算符和操作数之间插入行终止符时,其语义将发生更改的 AST 节点的封面。

JavaScript
t.isTerminatorless(node);

涵盖的节点

TypeScript

为 TypeScript 定义的 AST 节点的封面。

JavaScript
t.isTypeScript(node);

涵盖的节点

UnaryLike

UnaryExpression 和 SpreadElement 的一个封面。

JavaScript
t.isUnaryLike(node);

涵盖的节点

UserWhitespacable

已弃用。将在 Babel 8 中移除。

JavaScript
t.isUserWhitespacable(node);

涵盖的节点

While
JavaScript
t.isWhile(node);

涵盖的节点