@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
形狀
運算子
:"+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>"
(必填)左邊
:表達式 | 私有名稱
(必填)right
:Expression
(必要)
bindExpression
t.bindExpression(object, callee);
另請參閱 t.isBindExpression(node, opts)
和 t.assertBindExpression(node, opts)
。
AST 節點 BindExpression
形狀
物件
:表達式
(必填)呼叫
:表達式
(必填)
別名:表達式
blockStatement
t.blockStatement(body, directives);
另請參閱 t.isBlockStatement(node, opts)
和 t.assertBlockStatement(node, opts)
。
AST 節點 BlockStatement
形狀
主體
:陳述式陣列<Statement>
(必填)指令
:指令陣列<Directive>
(預設:[]
)
booleanLiteral
t.booleanLiteral(value);
另請參閱 t.isBooleanLiteral(node, opts)
和 t.assertBooleanLiteral(node, opts)
。
AST 節點 BooleanLiteral
形狀
值
:布林值
(必填)
別名:Standardized
、Expression
、Pureish
、Literal
、Immutable
booleanLiteralTypeAnnotation
t.booleanLiteralTypeAnnotation(value);
另請參閱 t.isBooleanLiteralTypeAnnotation(node, opts)
和 t.assertBooleanLiteralTypeAnnotation(node, opts)
。
AST 節點 BooleanLiteralTypeAnnotation
形狀
值
:布林值
(必填)
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
形狀
宣告
:流程
(預設:null
)指定符
:陣列<匯出指定符 | 匯出命名空間指定符>
(預設:null
)來源
:字串文字
(預設:null
)預設
:布林值
(預設:null
,從建構函式中排除)
別名:Flow
、FlowDeclaration
、Statement
、Declaration
宣告函式
t.declareFunction(id);
另請參閱 t.isDeclareFunction(node, opts)
和 t.assertDeclareFunction(node, opts)
。
AST 節點 宣告函式
形狀
id
:Identifier
(必填)謂詞
:已宣告謂詞
(預設:null
,從建構函式中排除)
別名:Flow
、FlowDeclaration
、Statement
、Declaration
宣告介面
t.declareInterface(id, typeParameters, extends, body);
另請參閱 t.isDeclareInterface(node, opts)
和 t.assertDeclareInterface(node, opts)
。
AST 節點 宣告介面
形狀
id
:Identifier
(必填)typeParameters
:TypeParameterDeclaration
(預設值:null
)extends
:Array<InterfaceExtends>
(預設值:null
)body
:ObjectTypeAnnotation
(必要)
別名:Flow
、FlowDeclaration
、Statement
、Declaration
宣告模組
t.declareModule(id, body, kind);
另請參閱 t.isDeclareModule(node, opts)
和 t.assertDeclareModule(node, opts)
。
AST 節點 宣告模組
形狀
識別碼
:識別碼 | 字串文字
(必要)body
:BlockStatement
(必填)種類
:"CommonJS" | "ES"
(預設:null
)
別名:Flow
、FlowDeclaration
、Statement
、Declaration
宣告模組匯出
t.declareModuleExports(typeAnnotation);
另請參閱 t.isDeclareModuleExports(node, opts)
和 t.assertDeclareModuleExports(node, opts)
。
AST 節點 宣告模組匯出
形狀
類型註解
:類型註解
(必要)
別名:Flow
、FlowDeclaration
、Statement
、Declaration
宣告不透明類型
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
(必要)
decorator
t.decorator(expression);
另請參閱 t.isDecorator(node, opts)
和 t.assertDecorator(node, opts)
。
AST 節點 Decorator
形狀
expression
:Expression
(必要)
directive
t.directive(value);
另請參閱 t.isDirective(node, opts)
和 t.assertDirective(node, opts)
。
AST 節點 Directive
形狀
value
:DirectiveLiteral
(必要)
別名:Standardized
指令文字
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
)
別名:表達式
do while 敘述
t.doWhileStatement(test, body);
另請參閱 t.isDoWhileStatement(node, opts)
和 t.assertDoWhileStatement(node, opts)
。
AST 節點 DoWhileStatement
形狀
test
:Expression
(必要)body
:敘述
(必要)
空敘述
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
:陣列<EnumBooleanMember>
(必要)explicitType
:布林
(必要)hasUnknownMembers
:布林
(必要)
enumBooleanMember
t.enumBooleanMember(id);
另請參閱 t.isEnumBooleanMember(node, opts)
和 t.assertEnumBooleanMember(node, opts)
。
AST 節點 EnumBooleanMember
形狀
id
:Identifier
(必填)init
:BooleanLiteral
(必要)
別名:Flow
、EnumMember
enumDeclaration
t.enumDeclaration(id, body);
另請參閱 t.isEnumDeclaration(node, opts)
和 t.assertEnumDeclaration(node, opts)
。
AST 節點 EnumDeclaration
形狀
id
:Identifier
(必填)body
:EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody
(必要)
enumDefaultedMember
t.enumDefaultedMember(id);
另請參閱 t.isEnumDefaultedMember(node, opts)
和 t.assertEnumDefaultedMember(node, opts)
。
AST 節點 EnumDefaultedMember
形狀
id
:Identifier
(必填)
別名:Flow
、EnumMember
enumNumberBody
t.enumNumberBody(members);
另請參閱 t.isEnumNumberBody(node, opts)
和 t.assertEnumNumberBody(node, opts)
。
AST 節點 EnumNumberBody
形狀
members
:Array<EnumNumberMember>
(必要)explicitType
:布林
(必要)hasUnknownMembers
:布林
(必要)
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
:布林
(必要)hasUnknownMembers
:布林
(必要)
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
:布林
(必要)
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>
(預設:[]
)來源
:字串文字
(預設: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
:Identifier | StringLiteral
(必要)exportKind
:"type" | "value"
(預設值:null
,從建構函式中排除)
別名:Standardized
, ModuleSpecifier
表達式陳述式
t.expressionStatement(expression);
另請參閱 t.isExpressionStatement(node, opts)
和 t.assertExpressionStatement(node, opts)
。
AST 節點 ExpressionStatement
形狀
expression
:Expression
(必要)
檔案
t.file(program, comments, tokens);
另請參閱 t.isFile(node, opts)
和 t.assertFile(node, opts)
。
AST 節點 檔案
形狀
程式
:程式
(必要)註解
:陣列<註解區塊 | 註解行>
(預設:null
)符號
:陣列<任何>
(預設:null
)
別名:Standardized
forIn 陳述式
t.forInStatement(left, right, body);
另請參閱 t.isForInStatement(node, opts)
和 t.assertForInStatement(node, opts)
。
AST 節點 ForInStatement
形狀
左
:變數宣告 | LVal
(必要)right
:Expression
(必要)body
:敘述
(必要)
別名:標準化
、可作用域
、陳述式
、For
、區塊父
、迴圈
、ForX 陳述式
forOf 陳述式
t.forOfStatement(left, right, body, await);
另請參閱 t.isForOfStatement(node, opts)
和 t.assertForOfStatement(node, opts)
。
AST 節點 ForOfStatement
形狀
左
:變數宣告 | LVal
(必要)right
:Expression
(必要)body
:敘述
(必要)await
:布林
(預設:false
)
別名:標準化
、可作用域
、陳述式
、For
、區塊父
、迴圈
、ForX 陳述式
for 陳述式
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
:敘述
(必要)
別名: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
形狀
標籤
:識別碼
(必填)body
:敘述
(必要)
logicalExpression
t.logicalExpression(operator, left, right);
另請參閱 t.isLogicalExpression(node, opts)
和 t.assertLogicalExpression(node, opts)
。
AST 節點 LogicalExpression
形狀
運算子
:"||" | "&&" | "??"
(必填)左
:表達式
(必填)right
:Expression
(必要)
memberExpression
t.memberExpression(object, property, computed, optional);
另請參閱 t.isMemberExpression(node, opts)
和 t.assertMemberExpression(node, opts)
。
AST 節點 MemberExpression
形狀
物件
:表達式 | 超級
(必填)屬性
:如果是運算,則為表達式
,否則為識別碼
(必填)computed
:boolean
(預設值:false
)可選
:true | false
(預設:null
)
metaProperty
t.metaProperty(meta, property);
另請參閱 t.isMetaProperty(node, opts)
和 t.assertMetaProperty(node, opts)
。
AST 節點 MetaProperty
形狀
元
:識別碼
(必填)屬性
:識別碼
(必填)
mixedTypeAnnotation
t.mixedTypeAnnotation();
另請參閱 t.isMixedTypeAnnotation(node, opts)
和 t.assertMixedTypeAnnotation(node, opts)
。
別名:Flow
、FlowType
、FlowBaseAnnotation
moduleExpression
t.moduleExpression(body);
另請參閱 t.isModuleExpression(node, opts)
和 t.assertModuleExpression(node, opts)
。
AST 節點 ModuleExpression
形狀
body
:Program
(必要)
別名:表達式
newExpression
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
,從建構函數中排除)
noop
t.noop();
另請參閱 t.isNoop(node, opts)
和 t.assertNoop(node, opts)
。
nullLiteral
t.nullLiteral();
另請參閱 t.isNullLiteral(node, opts)
和 t.assertNullLiteral(node, opts)
。
別名:Standardized
、Expression
、Pureish
、Literal
、Immutable
nullLiteralTypeAnnotation
t.nullLiteralTypeAnnotation();
另請參閱 t.isNullLiteralTypeAnnotation(node, opts)
和 t.assertNullLiteralTypeAnnotation(node, opts)
。
別名:Flow
、FlowType
、FlowBaseAnnotation
nullableTypeAnnotation
t.nullableTypeAnnotation(typeAnnotation);
另請參閱 t.isNullableTypeAnnotation(node, opts)
和 t.assertNullableTypeAnnotation(node, opts)
。
AST 節點 NullableTypeAnnotation
形狀
typeAnnotation
:FlowType
(必要)
numberLiteralTypeAnnotation
t.numberLiteralTypeAnnotation(value);
另請參閱 t.isNumberLiteralTypeAnnotation(node, opts)
和 t.assertNumberLiteralTypeAnnotation(node, opts)
。
AST 節點 NumberLiteralTypeAnnotation
形狀
value
:number
(必填)
numberTypeAnnotation
t.numberTypeAnnotation();
另請參閱 t.isNumberTypeAnnotation(node, opts)
和 t.assertNumberTypeAnnotation(node, opts)
。
別名:Flow
、FlowType
、FlowBaseAnnotation
numericLiteral
t.numericLiteral(value);
另請參閱 t.isNumericLiteral(node, opts)
和 t.assertNumericLiteral(node, opts)
。
AST 節點 NumericLiteral
形狀
value
:非負有限number
(必填)
別名:Standardized
、Expression
、Pureish
、Literal
、Immutable
objectExpression
t.objectExpression(properties);
另請參閱 t.isObjectExpression(node, opts)
和 t.assertObjectExpression(node, opts)
。
AST 節點 ObjectExpression
形狀
properties
:Array<ObjectMethod | ObjectProperty | SpreadElement>
(必填)
objectMethod
t.objectMethod(kind, key, params, body, computed, generator, async);
另請參閱 t.isObjectMethod(node, opts)
和 t.assertObjectMethod(node, opts)
。
AST 節點 ObjectMethod
形狀
kind
:"method" | "get" | "set"
(預設:'method'
)key
:如果計算後為Expression
,否則為Identifier | Literal
(必填)params
: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
objectPattern
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
objectProperty
t.objectProperty(key, value, computed, shorthand, decorators);
另請參閱 t.isObjectProperty(node, opts)
和 t.assertObjectProperty(node, opts)
。
AST 節點 ObjectProperty
形狀
key
:如果計算後為Expression
,否則為Identifier | Literal
(必填)value
:Expression | PatternLike
(必要)computed
:boolean
(預設值:false
)shorthand
:boolean
(預設:false
)decorators
:Array<Decorator>
(預設值:null
)
別名:Standardized
、UserWhitespacable
、Property
、ObjectMember
objectTypeAnnotation
t.objectTypeAnnotation(properties, indexers, callProperties, internalSlots, exact);
另請參閱 t.isObjectTypeAnnotation(node, opts)
和 t.assertObjectTypeAnnotation(node, opts)
。
AST 節點 ObjectTypeAnnotation
形狀
properties
:Array<ObjectTypeProperty | ObjectTypeSpreadProperty>
(必要)indexers
:Array<ObjectTypeIndexer>
(預設:[]
)callProperties
:Array<ObjectTypeCallProperty>
(預設:[]
)internalSlots
:Array<ObjectTypeInternalSlot>
(預設:[]
)exact
:boolean
(預設:false
)inexact
:boolean
(預設:null
,排除在建構函數之外)
objectTypeCallProperty
t.objectTypeCallProperty(value);
另請參閱 t.isObjectTypeCallProperty(node, opts)
和 t.assertObjectTypeCallProperty(node, opts)
。
AST 節點 ObjectTypeCallProperty
形狀
value
:FlowType
(必要)static
:boolean
(必要)
objectTypeIndexer
t.objectTypeIndexer(id, key, value, variance);
另請參閱 t.isObjectTypeIndexer(node, opts)
和 t.assertObjectTypeIndexer(node, opts)
。
AST 節點 ObjectTypeIndexer
形狀
id
:Identifier
(預設值:null
)key
:FlowType
(必要)value
:FlowType
(必要)variance
:Variance
(預設:null
)static
:boolean
(必要)
objectTypeInternalSlot
t.objectTypeInternalSlot(id, value, optional, static, method);
另請參閱 t.isObjectTypeInternalSlot(node, opts)
和 t.assertObjectTypeInternalSlot(node, opts)
。
AST 節點 ObjectTypeInternalSlot
形狀
id
:Identifier
(必填)value
:FlowType
(必要)optional
:boolean
(必要)static
:boolean
(必要)method
:boolean
(必要)
objectTypeProperty
t.objectTypeProperty(key, value, variance);
另請參閱 t.isObjectTypeProperty(node, opts)
和 t.assertObjectTypeProperty(node, opts)
。
AST 節點 ObjectTypeProperty
形狀
key
:Identifier | StringLiteral
(必要)value
:FlowType
(必要)variance
:Variance
(預設:null
)kind
:"init" | "get" | "set"
(必要)method
:boolean
(必要)optional
:boolean
(必要)proto
:boolean
(必要)static
:boolean
(必要)
objectTypeSpreadProperty
t.objectTypeSpreadProperty(argument);
另請參閱 t.isObjectTypeSpreadProperty(node, opts)
和 t.assertObjectTypeSpreadProperty(node, opts)
。
AST 節點 ObjectTypeSpreadProperty
形狀
argument
:FlowType
(必要)
opaqueType
t.opaqueType(id, typeParameters, supertype, impltype);
另請參閱 t.isOpaqueType(node, opts)
和 t.assertOpaqueType(node, opts)
。
AST 節點 OpaqueType
形狀
id
:Identifier
(必填)typeParameters
:TypeParameterDeclaration
(預設值:null
)supertype
:FlowType
(預設:null
)impltype
:FlowType
(必要)
別名:Flow
、FlowDeclaration
、Statement
、Declaration
optionalCallExpression
t.optionalCallExpression(callee, arguments, optional);
另請參閱 t.isOptionalCallExpression(node, opts)
和 t.assertOptionalCallExpression(node, opts)
。
AST 節點 OptionalCallExpression
形狀
呼叫
:表達式
(必填)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
形狀
物件
:表達式
(必填)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
形狀
呼叫
:表達式
(必填)
別名:表達式
pipelinePrimaryTopicReference
t.pipelinePrimaryTopicReference();
另請參閱 t.isPipelinePrimaryTopicReference(node, opts)
和 t.assertPipelinePrimaryTopicReference(node, opts)
。
別名:表達式
pipelineTopicExpression
t.pipelineTopicExpression(expression);
另請參閱 t.isPipelineTopicExpression(node, opts)
和 t.assertPipelineTopicExpression(node, opts)
。
AST 節點 PipelineTopicExpression
形狀
expression
:Expression
(必要)
別名:表達式
placeholder
t.placeholder(expectedNode, name);
另請參閱 t.isPlaceholder(node, opts)
和 t.assertPlaceholder(node, opts)
。
AST 節點 Placeholder
形狀
expectedNode
:"Identifier" | "StringLiteral" | "Expression" | "Statement" | "Declaration" | "BlockStatement" | "ClassBody" | "Pattern"
(必填)name
:Identifier
(必填)
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
形狀
主體
:陳述式陣列<Statement>
(必填)指令
:指令陣列<Directive>
(預設:[]
)sourceType
:"script" | "module"
(預設值:'script'
)interpreter
:InterpreterDirective
(預設值:null
)
別名:Standardized
、Scopable
、BlockParent
、Block
qualifiedTypeIdentifier
t.qualifiedTypeIdentifier(id, qualification);
另請參閱 t.isQualifiedTypeIdentifier(node, opts)
和 t.assertQualifiedTypeIdentifier(node, opts)
。
AST 節點 QualifiedTypeIdentifier
形狀
id
:Identifier
(必填)qualification
:Identifier | QualifiedTypeIdentifier
(必填)
別名:Flow
recordExpression
t.recordExpression(properties);
另請參閱 t.isRecordExpression(node, opts)
和 t.assertRecordExpression(node, opts)
。
AST 節點 RecordExpression
形狀
properties
:Array<ObjectProperty | SpreadElement>
(必填)
別名:表達式
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
形狀
主體
:陳述式陣列<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
形狀
識別碼
:識別碼 | 字串文字
(必要)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
形狀
主體
:陳述式陣列<Statement>
(必填)
別名:TypeScript
、Scopable
、Block
、BlockParent
、FunctionParent
tsModuleDeclaration
t.tsModuleDeclaration(id, body);
另請參閱 t.isTSModuleDeclaration(node, opts)
和 t.assertTSModuleDeclaration(node, opts)
。
AST 節點 TSModuleDeclaration
形狀
識別碼
:識別碼 | 字串文字
(必要)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
形狀
標籤
:識別碼
(必填)elementType
:TSType
(必要)optional
:boolean
(預設:false
)
別名:TypeScript
tsNamespaceExportDeclaration
t.tsNamespaceExportDeclaration(id);
另請參閱 t.isTSNamespaceExportDeclaration(node, opts)
和 t.assertTSNamespaceExportDeclaration(node, opts)
。
AST 節點 TSNamespaceExportDeclaration
形狀
id
:Identifier
(必填)
tsNeverKeyword
t.tsNeverKeyword();
另請參閱 t.isTSNeverKeyword(node, opts)
和 t.assertTSNeverKeyword(node, opts)
。
別名:TypeScript
、TSType
、TSBaseType
tsNonNullExpression
t.tsNonNullExpression(expression);
另請參閱 t.isTSNonNullExpression(node, opts)
和 t.assertTSNonNullExpression(node, opts)
。
AST 節點 TSNonNullExpression
形狀
expression
:Expression
(必要)
別名:TypeScript
、Expression
、LVal
、PatternLike
tsNullKeyword
t.tsNullKeyword();
另請參閱 t.isTSNullKeyword(node, opts)
和 t.assertTSNullKeyword(node, opts)
。
別名:TypeScript
、TSType
、TSBaseType
tsNumberKeyword
t.tsNumberKeyword();
另請參閱 t.isTSNumberKeyword(node, opts)
和 t.assertTSNumberKeyword(node, opts)
。
別名:TypeScript
、TSType
、TSBaseType
tsObjectKeyword
t.tsObjectKeyword();
另請參閱 t.isTSObjectKeyword(node, opts)
和 t.assertTSObjectKeyword(node, opts)
。
別名:TypeScript
、TSType
、TSBaseType
tsOptionalType
t.tsOptionalType(typeAnnotation);
另請參閱 t.isTSOptionalType(node, opts)
和 t.assertTSOptionalType(node, opts)
。
AST 節點 TSOptionalType
形狀
typeAnnotation
:TSType
(必要)
別名:TypeScript
、TSType
tsParameterProperty
t.tsParameterProperty(parameter);
另請參閱 t.isTSParameterProperty(node, opts)
和 t.assertTSParameterProperty(node, opts)
。
AST 節點 TSParameterProperty
形狀
parameter
:Identifier | AssignmentPattern
(必填)accessibility
:"public" | "private" | "protected"
(預設值:null
,排除於建構函數之外)decorators
:Array<Decorator>
(預設值:null
,從建立器函數中排除)override
:boolean
(預設值:null
,從建構函數中排除)readonly
:boolean
(預設值:null
,排除於建構函數之外)
別名:TypeScript
、LVal
tsParenthesizedType
t.tsParenthesizedType(typeAnnotation);
另請參閱 t.isTSParenthesizedType(node, opts)
和 t.assertTSParenthesizedType(node, opts)
。
AST 節點 TSParenthesizedType
形狀
typeAnnotation
:TSType
(必要)
別名:TypeScript
、TSType
tsPropertySignature
t.tsPropertySignature(key, typeAnnotation);
另請參閱 t.isTSPropertySignature(node, opts)
和 t.assertTSPropertySignature(node, opts)
。
AST 節點 TSPropertySignature
形狀
key
:Expression
(必填)typeAnnotation
:TSTypeAnnotation
(預設值:null
)computed
:boolean
(預設值:false
,從建構函數中排除)kind
:"get" | "set"
(必需)optional
:boolean
(預設值:null
,從建立器函數中排除)readonly
:boolean
(預設值:null
,排除於建構函數之外)
tsQualifiedName
t.tsQualifiedName(left, right);
另請參閱 t.isTSQualifiedName(node, opts)
和 t.assertTSQualifiedName(node, opts)
。
AST 節點 TSQualifiedName
形狀
left
:TSEntityName
(必需)right
:Identifier
(必需)
tsRestType
t.tsRestType(typeAnnotation);
另請參閱 t.isTSRestType(node, opts)
和 t.assertTSRestType(node, opts)
。
AST 節點 TSRestType
形狀
typeAnnotation
:TSType
(必要)
別名:TypeScript
、TSType
tsSatisfiesExpression
t.tsSatisfiesExpression(expression, typeAnnotation);
歷史
版本 | 變更 |
---|---|
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
:布林值
(預設值:false
)
別名:Standardized
templateLiteral
t.templateLiteral(quasis, expressions);
另請參閱 t.isTemplateLiteral(node, opts)
和 t.assertTemplateLiteral(node, opts)
。
AST 節點 TemplateLiteral
形狀
quasis
:陣列<TemplateElement>
(必要)expressions
:陣列<Expression | TSType>
(必要)
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)
。
別名:表達式
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>
(預設:[]
)
別名:表達式
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
(必要)類型註解
:類型註解
(必要)
別名: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
:敘述
(必要)
withStatement
t.withStatement(object, body);
另請參閱 t.isWithStatement(node, opts)
和 t.assertWithStatement(node, opts)
。
AST 節點 WithStatement
形狀
物件
:表達式
(必填)body
:敘述
(必要)
yieldExpression
t.yieldExpression(argument, delegate);
另請參閱 t.isYieldExpression(node, opts)
和 t.assertYieldExpression(node, opts)
。
AST 節點 YieldExpression
形狀
argument
:Expression
(預設值:null
)delegate
:boolean
(預設:false
)
別名:Standardized
、Expression
、Terminatorless
別名
存取器
已棄用。將在 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);
涵蓋的節點
ArrowFunctionExpression
BlockStatement
CatchClause
ClassMethod
ClassPrivateMethod
DoWhileStatement
ForInStatement
ForOfStatement
ForStatement
FunctionDeclaration
函數表達式
物件方法
Program
靜態區塊
開關陳述式
TSModuleBlock
While 陳述式
類別
ClassExpression 和 ClassDeclaration 的封裝,它們共用相同的 AST 形狀。
t.isClass(node);
涵蓋的節點
完成陳述式
表示完成記錄的陳述式。換句話說,它們定義程式的控制流程,例如迴圈何時中斷或動作擲出重大錯誤。
t.isCompletionStatement(node);
涵蓋的節點
條件式
ConditionalExpression 和 IfStatement 的封裝,它們共用相同的 AST 形狀。
t.isConditional(node);
涵蓋的節點
宣告
任何宣告的封裝。
t.isDeclaration(node);
涵蓋的節點
類別宣告
宣告類別
宣告匯出全部宣告
宣告匯出宣告
宣告函數
宣告介面
宣告模組
宣告模組匯出
宣告不透明類型
宣告類型別名
宣告變數
列舉宣告
匯出全部宣告
匯出預設宣告
匯出命名宣告
FunctionDeclaration
匯入宣告
介面宣告
不透明類型
TS 宣告函數
TS 列舉宣告
TS 介面宣告
TS 模組宣告
TS 類型別名宣告
類型別名
變數宣告
列舉主體
Flow 列舉主體的涵蓋範圍。
t.isEnumBody(node);
涵蓋的節點
列舉成員
Flow 列舉成員的涵蓋範圍。
t.isEnumMember(node);
涵蓋的節點
匯出宣告
任何 ExportDeclaration 的涵蓋範圍。
t.isExportDeclaration(node);
涵蓋的節點
表達式
任何 Expression 的涵蓋範圍。
t.isExpression(node);
涵蓋的節點
陣列表達式
ArrowFunctionExpression
指定表達式
Await 表達式
BigInt 文字
BinaryExpression
Bind 表達式
布林文字
呼叫表達式
類別表達式
條件式表達式
十進位文字
Do 表達式
函數表達式
識別碼
匯入
匯入表達式
JSX 元素
JSX 片段
LogicalExpression
成員表達式
Meta 屬性
模組表達式
New 表達式
Null 文字
數字文字
物件表達式
選擇性呼叫表達式
選擇性成員表達式
括號表達式
管線裸功能
管線主要主題參考
管線主題表達式
記錄表達式
RegExp 文字
順序表達式
字串文字
Super
TSAs 表達式
TSInstantiation 表達式
TSNonNull 表達式
TSSatisfies 表達式
TSTypeAssertion
標記範本表達式
範本文字
This 表達式
主題參考
TupleExpression
TypeCastExpression
UnaryExpression
UpdateExpression
YieldExpression
ExpressionWrapper
不具備執行時期語意的表達式包裝器。
t.isExpressionWrapper(node);
涵蓋的節點
Flow
Flow 定義的 AST 節點涵蓋範圍。
t.isFlow(node);
涵蓋的節點
AnyTypeAnnotation
ArrayTypeAnnotation
BooleanLiteralTypeAnnotation
BooleanTypeAnnotation
ClassImplements
宣告類別
宣告匯出全部宣告
宣告匯出宣告
宣告函數
宣告介面
宣告模組
宣告模組匯出
宣告不透明類型
宣告類型別名
宣告變數
DeclaredPredicate
EmptyTypeAnnotation
列舉布林主體
列舉布林成員
列舉宣告
列舉預設成員
列舉數字主體
列舉數字成員
列舉字串主體
列舉字串成員
列舉符號主體
ExistsTypeAnnotation
FunctionTypeAnnotation
FunctionTypeParam
GenericTypeAnnotation
IndexedAccessType
InferredPredicate
介面宣告
InterfaceExtends
InterfaceTypeAnnotation
IntersectionTypeAnnotation
MixedTypeAnnotation
NullLiteralTypeAnnotation
NullableTypeAnnotation
NumberLiteralTypeAnnotation
NumberTypeAnnotation
ObjectTypeAnnotation
ObjectTypeCallProperty
ObjectTypeIndexer
ObjectTypeInternalSlot
ObjectTypeProperty
ObjectTypeSpreadProperty
不透明類型
OptionalIndexedAccessType
QualifiedTypeIdentifier
StringLiteralTypeAnnotation
StringTypeAnnotation
SymbolTypeAnnotation
ThisTypeAnnotation
TupleTypeAnnotation
類型別名
TypeAnnotation
TypeCastExpression
TypeParameter
TypeParameterDeclaration
TypeParameterInstantiation
TypeofTypeAnnotation
UnionTypeAnnotation
Variance
VoidTypeAnnotation
FlowBaseAnnotation
主要 Flow 型別註解的涵蓋範圍。
t.isFlowBaseAnnotation(node);
涵蓋的節點
AnyTypeAnnotation
BooleanTypeAnnotation
EmptyTypeAnnotation
MixedTypeAnnotation
NullLiteralTypeAnnotation
NumberTypeAnnotation
StringTypeAnnotation
SymbolTypeAnnotation
ThisTypeAnnotation
VoidTypeAnnotation
FlowDeclaration
Flow 宣告的涵蓋範圍。
t.isFlowDeclaration(node);
涵蓋的節點
FlowPredicate
Flow 謂詞的涵蓋範圍。
t.isFlowPredicate(node);
涵蓋的節點
FlowType
Flow 型別註解的涵蓋範圍。
t.isFlowType(node);
涵蓋的節點
AnyTypeAnnotation
ArrayTypeAnnotation
BooleanLiteralTypeAnnotation
BooleanTypeAnnotation
EmptyTypeAnnotation
ExistsTypeAnnotation
FunctionTypeAnnotation
GenericTypeAnnotation
IndexedAccessType
InterfaceTypeAnnotation
IntersectionTypeAnnotation
MixedTypeAnnotation
NullLiteralTypeAnnotation
NullableTypeAnnotation
NumberLiteralTypeAnnotation
NumberTypeAnnotation
ObjectTypeAnnotation
OptionalIndexedAccessType
StringLiteralTypeAnnotation
StringTypeAnnotation
SymbolTypeAnnotation
ThisTypeAnnotation
TupleTypeAnnotation
TypeofTypeAnnotation
UnionTypeAnnotation
VoidTypeAnnotation
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);
涵蓋的節點
ArrowFunctionExpression
ClassMethod
ClassPrivateMethod
FunctionDeclaration
函數表達式
物件方法
靜態區塊
TSModuleBlock
Immutable
不可變物件和 JSX 元素的涵蓋範圍。如果在建立後無法定義其他屬性,則物件為 不可變。
t.isImmutable(node);
涵蓋的節點
BigInt 文字
布林文字
十進位文字
JSXAttribute
JSXClosingElement
JSXClosingFragment
JSX 元素
JSXExpressionContainer
JSX 片段
JSXOpeningElement
JSXOpeningFragment
JSXSpreadChild
JSXText
Null 文字
數字文字
字串文字
ImportOrExportDeclaration
歷史
版本 | 變更 |
---|---|
v7.21.0 | 已引入 |
ImportDeclaration 和 ExportDeclaration 的涵蓋範圍。
t.isImportOrExportDeclaration(node);
涵蓋的節點
JSX
為 JSX 定義的 AST 節點的涵蓋範圍。
t.isJSX(node);
涵蓋的節點
JSXAttribute
JSXClosingElement
JSXClosingFragment
JSX 元素
JSXEmptyExpression
JSXExpressionContainer
JSX 片段
JSXIdentifier
JSXMemberExpression
JSXNamespacedName
JSXOpeningElement
JSXOpeningFragment
JSXSpreadAttribute
JSXSpreadChild
JSXText
LVal
涵蓋用於賦值運算式的 left
和 ForXStatement 的左手邊運算式。
t.isLVal(node);
涵蓋的節點
ArrayPattern
AssignmentPattern
識別碼
成員表達式
ObjectPattern
RestElement
TSAs 表達式
TSNonNull 表達式
TSParameterProperty
TSSatisfies 表達式
TSTypeAssertion
Literal
涵蓋 Literal、Regular Expression Literal 和 Template Literal。
t.isLiteral(node);
涵蓋的節點
Loop
迴圈語法的涵蓋範圍。
t.isLoop(node);
涵蓋的節點
方法
物件方法和類別方法的涵蓋範圍。
t.isMethod(node);
涵蓋的節點
雜項
有時對開發有用的非標準 AST 類型涵蓋範圍。
t.isMiscellaneous(node);
涵蓋的節點
ModuleDeclaration
歷史
版本 | 變更 |
---|---|
v7.21.0 | 已棄用 |
已棄用,請改用 ImportOrExportDeclaration
。查看 PR #15266 以取得遷移注意事項。
t.isModuleDeclaration(node);
涵蓋的節點
ModuleSpecifier
涵蓋匯入和匯出指定項。注意:它不是規範中定義的 ModuleSpecifier。
t.isModuleSpecifier(node);
涵蓋的節點
ExportDefaultSpecifier
ExportNamespaceSpecifier
ExportSpecifier
ImportDefaultSpecifier
ImportNamespaceSpecifier
ImportSpecifier
ObjectMember
涵蓋物件文字中的 成員。
t.isObjectMember(node);
涵蓋的節點
Pattern
涵蓋 BindingPattern,但排除識別項。
t.isPattern(node);
涵蓋的節點
PatternLike
一個 BindingPattern 的封面。
t.isPatternLike(node);
涵蓋的節點
ArrayPattern
AssignmentPattern
識別碼
ObjectPattern
RestElement
TSAs 表達式
TSNonNull 表達式
TSSatisfies 表達式
TSTypeAssertion
私有
一個私有類別元素和私有識別碼的封面。
t.isPrivate(node);
涵蓋的節點
屬性
一個物件屬性和類別屬性的封面。
t.isProperty(node);
涵蓋的節點
Pureish
一個沒有副作用的 AST 節點的封面。換句話說,如果它們被評估超過一次,則沒有可觀察到的行為改變。
t.isPureish(node);
涵蓋的節點
Scopable
一個 FunctionParent 和 BlockParent 的封面。
t.isScopable(node);
涵蓋的節點
ArrowFunctionExpression
BlockStatement
CatchClause
類別宣告
類別表達式
ClassMethod
ClassPrivateMethod
DoWhileStatement
ForInStatement
ForOfStatement
ForStatement
FunctionDeclaration
函數表達式
物件方法
Program
靜態區塊
開關陳述式
TSModuleBlock
While 陳述式
標準化
一個屬於官方 ECMAScript 規範一部分的 AST 節點的封面。
t.isStandardized(node);
涵蓋的節點
陣列表達式
ArrayPattern
ArrowFunctionExpression
指定表達式
AssignmentPattern
Await 表達式
BigInt 文字
BinaryExpression
BlockStatement
布林文字
中斷陳述式
呼叫表達式
CatchClause
ClassAccessorProperty
ClassBody
類別宣告
類別表達式
ClassMethod
ClassPrivateMethod
ClassPrivateProperty
ClassProperty
條件式表達式
繼續陳述式
DebuggerStatement
Directive
DirectiveLiteral
DoWhileStatement
EmptyStatement
匯出全部宣告
匯出預設宣告
匯出命名宣告
ExportNamespaceSpecifier
ExportSpecifier
ExpressionStatement
File
ForInStatement
ForOfStatement
ForStatement
FunctionDeclaration
函數表達式
識別碼
If 陳述式
匯入
匯入宣告
ImportDefaultSpecifier
匯入表達式
ImportNamespaceSpecifier
ImportSpecifier
InterpreterDirective
LabeledStatement
LogicalExpression
成員表達式
Meta 屬性
New 表達式
Null 文字
數字文字
物件表達式
物件方法
ObjectPattern
ObjectProperty
選擇性呼叫表達式
選擇性成員表達式
括號表達式
PrivateName
Program
RegExp 文字
RestElement
傳回陳述式
順序表達式
SpreadElement
靜態區塊
字串文字
Super
SwitchCase
開關陳述式
標記範本表達式
TemplateElement
範本文字
This 表達式
擲出陳述式
TryStatement
UnaryExpression
UpdateExpression
變數宣告
VariableDeclarator
While 陳述式
WithStatement
YieldExpression
陳述
任何 陳述 的封面。
t.isStatement(node);
涵蓋的節點
BlockStatement
中斷陳述式
類別宣告
繼續陳述式
DebuggerStatement
宣告類別
宣告匯出全部宣告
宣告匯出宣告
宣告函數
宣告介面
宣告模組
宣告模組匯出
宣告不透明類型
宣告類型別名
宣告變數
DoWhileStatement
EmptyStatement
列舉宣告
匯出全部宣告
匯出預設宣告
匯出命名宣告
ExpressionStatement
ForInStatement
ForOfStatement
ForStatement
FunctionDeclaration
If 陳述式
匯入宣告
介面宣告
LabeledStatement
不透明類型
傳回陳述式
開關陳述式
TS 宣告函數
TS 列舉宣告
TSExportAssignment
TSImportEqualsDeclaration
TS 介面宣告
TS 模組宣告
TSNamespaceExportDeclaration
TS 類型別名宣告
擲出陳述式
TryStatement
類型別名
變數宣告
While 陳述式
WithStatement
TSBaseType
一個主要的 TypeScript 型別註解的封面。
t.isTSBaseType(node);
涵蓋的節點
TSAnyKeyword
TSBigIntKeyword
TSBooleanKeyword
TSIntrinsicKeyword
TSLiteralType
TSNeverKeyword
TSNullKeyword
TSNumberKeyword
TSObjectKeyword
TSStringKeyword
TSSymbolKeyword
TSThisType
TSUndefinedKeyword
TSUnknownKeyword
TSVoidKeyword
TSEntityName
ts 實體的涵蓋範圍。
t.isTSEntityName(node);
涵蓋的節點
TSType
TypeScript 型別註解的涵蓋範圍。
t.isTSType(node);
涵蓋的節點
TSAnyKeyword
TSArrayType
TSBigIntKeyword
TSBooleanKeyword
TSConditionalType
TSConstructorType
TSExpressionWithTypeArguments
TSFunctionType
TSImportType
TSIndexedAccessType
TSInferType
TSIntersectionType
TSIntrinsicKeyword
TSLiteralType
TSMappedType
TSNeverKeyword
TSNullKeyword
TSNumberKeyword
TSObjectKeyword
TSOptionalType
TSParenthesizedType
TSRestType
TSStringKeyword
TSSymbolKeyword
TSThisType
TSTupleType
TSTypeLiteral
TSTypeOperator
TSTypePredicate
TSTypeQuery
TSTypeReference
TSUndefinedKeyword
TSUnionType
TSUnknownKeyword
TSVoidKeyword
TSTypeElement
TypeScript 型別宣告的涵蓋範圍。
t.isTSTypeElement(node);
涵蓋的節點
TSCallSignatureDeclaration
TSConstructSignatureDeclaration
TSIndexSignature
TSMethodSignature
TSPropertySignature
Terminatorless
運算子與運算元之間插入換行符號時,語意會變更的 AST 節點涵蓋範圍。
t.isTerminatorless(node);
涵蓋的節點
TypeScript
為 TypeScript 定義的 AST 節點涵蓋範圍。
t.isTypeScript(node);
涵蓋的節點
TSAnyKeyword
TSArrayType
TSAs 表達式
TSBigIntKeyword
TSBooleanKeyword
TSCallSignatureDeclaration
TSConditionalType
TSConstructSignatureDeclaration
TSConstructorType
TS 宣告函數
TSDeclareMethod
TS 列舉宣告
TSEnumMember
TSExportAssignment
TSExpressionWithTypeArguments
TSExternalModuleReference
TSFunctionType
TSImportEqualsDeclaration
TSImportType
TSIndexSignature
TSIndexedAccessType
TSInferType
TSInstantiation 表達式
TSInterfaceBody
TS 介面宣告
TSIntersectionType
TSIntrinsicKeyword
TSLiteralType
TSMappedType
TSMethodSignature
TSModuleBlock
TS 模組宣告
TSNamedTupleMember
TSNamespaceExportDeclaration
TSNeverKeyword
TSNonNull 表達式
TSNullKeyword
TSNumberKeyword
TSObjectKeyword
TSOptionalType
TSParameterProperty
TSParenthesizedType
TSPropertySignature
TSQualifiedName
TSRestType
TSSatisfies 表達式
TSStringKeyword
TSSymbolKeyword
TSThisType
TSTupleType
TS 類型別名宣告
TSTypeAnnotation
TSTypeAssertion
TSTypeLiteral
TSTypeOperator
TSTypeParameter
TSTypeParameterDeclaration
TSTypeParameterInstantiation
TSTypePredicate
TSTypeQuery
TSTypeReference
TSUndefinedKeyword
TSUnionType
TSUnknownKeyword
TSVoidKeyword
UnaryLike
UnaryExpression 和 SpreadElement 的涵蓋範圍。
t.isUnaryLike(node);
涵蓋的節點
UserWhitespacable
已棄用。將在 Babel 8 中移除。
t.isUserWhitespacable(node);
涵蓋的節點
物件方法
ObjectProperty
ObjectTypeCallProperty
ObjectTypeIndexer
ObjectTypeInternalSlot
ObjectTypeProperty
ObjectTypeSpreadProperty
While
DoWhileStatement 和 WhileStatement 的涵蓋範圍,它們共用相同的 AST 形狀。
t.isWhile(node);
涵蓋的節點