Babel types

Babel Types is a Lodash-esque utility library for AST nodes

安装

npm install --save-dev babel-types

API

anyTypeAnnotation

t.anyTypeAnnotation()

参见 t.isAnyTypeAnnotation(node, opts)t.assertAnyTypeAnnotation(node, opts)

别名: FlowFlowBaseAnnotation


arrayExpression

t.arrayExpression(elements)

参见 t.isArrayExpression(node, opts)t.assertArrayExpression(node, opts)

别名: Expression

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

arrayPattern

t.arrayPattern(elements, typeAnnotation)

参见 t.isArrayPattern(node, opts)t.assertArrayPattern(node, opts)

别名: PatternLVal

  • elements: Array<Identifier | Pattern | RestElement> (必填)
  • typeAnnotation (必填)
  • decorators: Array<Decorator> (默认为:null)

arrayTypeAnnotation

t.arrayTypeAnnotation(elementType)

参加 t.isArrayTypeAnnotation(node, opts)t.assertArrayTypeAnnotation(node, opts)

别名: Flow

  • elementType (必填)

arrowFunctionExpression

t.arrowFunctionExpression(params, body, async)

参见 t.isArrowFunctionExpression(node, opts)t.assertArrowFunctionExpression(node, opts)

别名: Scopable, Function, BlockParent, FunctionParent, Expression, Pureish

  • params: Array<LVal> (必填)
  • body: BlockStatement | Expression (必填)
  • async: boolean (默认为:false)
  • returnType (默认为:null)
  • typeParameters (默认为:null)

assignmentExpression

t.assignmentExpression(operator, left, right)

参见 t.isAssignmentExpression(node, opts)t.assertAssignmentExpression(node, opts)

别名: Expression

  • operator: string (必填)
  • left: LVal (必填)
  • right: Expression (必填)

assignmentPattern

t.assignmentPattern(left, right)

参见 t.isAssignmentPattern(node, opts)t.assertAssignmentPattern(node, opts)

别名: Pattern, LVal

  • left: Identifier (必填)
  • right: Expression (必填)
  • decorators: Array<Decorator> (默认为:null)

awaitExpression

t.awaitExpression(argument)

参见 t.isAwaitExpression(node, opts)t.assertAwaitExpression(node, opts)

别名: Expression, Terminatorless

  • argument: Expression (必填)

binaryExpression

t.binaryExpression(operator, left, right)

参见 t.isBinaryExpression(node, opts)t.assertBinaryExpression(node, opts)

别名: Binary, Expression

  • operator: '+' | '-' | '/' | '%' | '*' | '**' | '&' | '|' | '>>' | '>>>' | '<<' | '^' | '==' | '===' | '!=' | '!==' | 'in' | 'instanceof' | '>' | '<' | '>=' | '<=' (必填)
  • left: Expression (必填)
  • right: Expression (必填)

bindExpression

t.bindExpression(object, callee)

参见 t.isBindExpression(node, opts)t.assertBindExpression(node, opts)

别名: Expression

  • object (必填)
  • callee (必填)

blockStatement

t.blockStatement(body, directives)

参见 t.isBlockStatement(node, opts)t.assertBlockStatement(node, opts)

别名: Scopable, BlockParent, Block, Statement

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

booleanLiteral

t.booleanLiteral(value)

参见 t.isBooleanLiteral(node, opts)t.assertBooleanLiteral(node, opts)

别名: Expression, Pureish, Literal, Immutable

  • value: boolean (必填)

booleanLiteralTypeAnnotation

t.booleanLiteralTypeAnnotation()

参见 t.isBooleanLiteralTypeAnnotation(node, opts)t.assertBooleanLiteralTypeAnnotation(node, opts)

别名: Flow


booleanTypeAnnotation

t.booleanTypeAnnotation()

参见 t.isBooleanTypeAnnotation(node, opts)t.assertBooleanTypeAnnotation(node, opts)

别名: Flow, FlowBaseAnnotation


breakStatement

t.breakStatement(label)

参见 t.isBreakStatement(node, opts)t.assertBreakStatement(node, opts)

别名: Statement, Terminatorless, CompletionStatement

  • label: Identifier (默认为:null)

callExpression

t.callExpression(callee, arguments)

参见 t.isCallExpression(node, opts)t.assertCallExpression(node, opts)

别名: Expression

  • callee: Expression (必填)
  • arguments: Array<Expression | SpreadElement> (必填)

catchClause

t.catchClause(param, body)

参见 t.isCatchClause(node, opts)t.assertCatchClause(node, opts)

别名: Scopable

  • param: Identifier (必填)
  • body: BlockStatement (必填)

classBody

t.classBody(body)

参见 t.isClassBody(node, opts)t.assertClassBody(node, opts)

  • body: Array<ClassMethod | ClassProperty> (必填)

classDeclaration

t.classDeclaration(id, superClass, body, decorators)

参见 t.isClassDeclaration(node, opts)t.assertClassDeclaration(node, opts)

别名: Scopable, Class, Statement, Declaration, Pureish

  • id: Identifier (必填)
  • superClass: Expression (默认为:null)
  • body: ClassBody (必填)
  • decorators: Array<Decorator> (必填)
  • implements (默认为:null)
  • mixins (默认为:null)
  • superTypeParameters (默认为:null)
  • typeParameters (默认为:null)

classExpression

t.classExpression(id, superClass, body, decorators)

参见 t.isClassExpression(node, opts)t.assertClassExpression(node, opts)

别名: Scopable, Class, Expression, Pureish

  • id: Identifier (默认为:null)
  • superClass: Expression (默认为:null)
  • body: ClassBody (必填)
  • decorators: Array<Decorator> (必填)
  • implements (默认为:null)
  • mixins (默认为:null)
  • superTypeParameters (默认为:null)
  • typeParameters (默认为:null)

classImplements

t.classImplements(id, typeParameters)

参见 t.isClassImplements(node, opts)t.assertClassImplements(node, opts)

别名: Flow

  • id (必填)
  • typeParameters (必填)

classMethod

t.classMethod(kind, key, params, body, computed, static)

参见 t.isClassMethod(node, opts)t.assertClassMethod(node, opts)

别名: Function, Scopable, BlockParent, FunctionParent, Method

  • kind: "get" | "set" | "method" | "constructor" (默认为:'method')
  • keyif computed then Expression else Identifier | Literal (必填)
  • params: Array<LVal> (必填)
  • body: BlockStatement (必填)
  • computed: boolean (默认为:false)
  • static: boolean (默认为:false)
  • async: boolean (默认为:false)
  • decorators (默认为:null)
  • generator: boolean (默认为:false)
  • returnType (默认为:null)
  • typeParameters (默认为:null)

classProperty

t.classProperty(key, value, typeAnnotation, decorators, computed)

参见 t.isClassProperty(node, opts)t.assertClassProperty(node, opts)

别名: Property

  • key (必填)
  • value (必填)
  • typeAnnotation (必填)
  • decorators (必填)
  • computed: boolean (默认为:false)

conditionalExpression

t.conditionalExpression(test, consequent, alternate)

参见 t.isConditionalExpression(node, opts)t.assertConditionalExpression(node, opts)

别名: Expression, Conditional

  • test: Expression (必填)
  • consequent: Expression (必填)
  • alternate: Expression (必填)

continueStatement

t.continueStatement(label)

参见 t.isContinueStatement(node, opts)t.assertContinueStatement(node, opts)

别名: Statement, Terminatorless, CompletionStatement

  • label: Identifier (默认为:null)

debuggerStatement

t.debuggerStatement()

参见 t.isDebuggerStatement(node, opts)t.assertDebuggerStatement(node, opts)

别名: Statement


declareClass

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

参见 t.isDeclareClass(node, opts)t.assertDeclareClass(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)
  • typeParameters (必填)
  • extends (必填)
  • body (必填)

declareExportDeclaration

t.declareExportDeclaration(declaration, specifiers, source)

参见 t.isDeclareExportDeclaration(node, opts)t.assertDeclareExportDeclaration(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • declaration (必填)
  • specifiers (必填)
  • source (必填)

declareFunction

t.declareFunction(id)

参见 t.isDeclareFunction(node, opts)t.assertDeclareFunction(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)

declareInterface

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

参见 t.isDeclareInterface(node, opts)t.assertDeclareInterface(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)
  • typeParameters (必填)
  • extends (必填)
  • body (必填)

declareModule

t.declareModule(id, body)

参见 t.isDeclareModule(node, opts)t.assertDeclareModule(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)
  • body (必填)

declareModuleExports

t.declareModuleExports(typeAnnotation)

参见 t.isDeclareModuleExports(node, opts)t.assertDeclareModuleExports(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • typeAnnotation (必填)

declareOpaqueType

t.declareOpaqueType(id, typeParameters, supertype)

参见 t.isDeclareOpaqueType(node, opts)t.assertDeclareOpaqueType(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)
  • typeParameters (必填)
  • supertype (必填)

declareTypeAlias

t.declareTypeAlias(id, typeParameters, right)

参见 t.isDeclareTypeAlias(node, opts)t.assertDeclareTypeAlias(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)
  • typeParameters (必填)
  • right (必填)

declareVariable

t.declareVariable(id)

参见 t.isDeclareVariable(node, opts)t.assertDeclareVariable(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)

decorator

t.decorator(expression)

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

  • expression: Expression (必填)

directive

t.directive(value)

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

  • value: DirectiveLiteral (必填)

directiveLiteral

t.directiveLiteral(value)

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

  • value: string (必填)

doExpression

t.doExpression(body)

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

别名: Expression

  • body: BlockStatement (必填)

doWhileStatement

t.doWhileStatement(test, body)

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

别名: Statement, BlockParent, Loop, While, Scopable

  • test: Expression (必填)
  • body: Statement (必填)

emptyStatement

t.emptyStatement()

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

别名: Statement


emptyTypeAnnotation

t.emptyTypeAnnotation()

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

别名: Flow, FlowBaseAnnotation


existentialTypeParam

t.existentialTypeParam()

参见 t.isExistentialTypeParam(node, opts)t.assertExistentialTypeParam(node, opts)

别名: Flow


exportAllDeclaration

t.exportAllDeclaration(source)

参见 t.isExportAllDeclaration(node, opts)t.assertExportAllDeclaration(node, opts)

别名: Statement, Declaration, ModuleDeclaration, ExportDeclaration

  • source: StringLiteral (必填)

exportDefaultDeclaration

t.exportDefaultDeclaration(declaration)

参见 t.isExportDefaultDeclaration(node, opts)t.assertExportDefaultDeclaration(node, opts)

别名: Statement, Declaration, ModuleDeclaration, ExportDeclaration

  • declaration: FunctionDeclaration | ClassDeclaration | Expression (必填)

exportDefaultSpecifier

t.exportDefaultSpecifier(exported)

参见 t.isExportDefaultSpecifier(node, opts)t.assertExportDefaultSpecifier(node, opts)

别名: ModuleSpecifier

  • exported: Identifier (必填)

exportNamedDeclaration

t.exportNamedDeclaration(declaration, specifiers, source)

参见 t.isExportNamedDeclaration(node, opts)t.assertExportNamedDeclaration(node, opts)

别名: Statement, Declaration, ModuleDeclaration, ExportDeclaration

  • declaration: Declaration (默认为:null)
  • specifiers: Array<ExportSpecifier> (必填)
  • source: StringLiteral (默认为:null)

exportNamespaceSpecifier

t.exportNamespaceSpecifier(exported)

参见 t.isExportNamespaceSpecifier(node, opts)t.assertExportNamespaceSpecifier(node, opts)

别名: ModuleSpecifier

  • exported: Identifier (必填)

exportSpecifier

t.exportSpecifier(local, exported)

参见 t.isExportSpecifier(node, opts)t.assertExportSpecifier(node, opts)

别名: ModuleSpecifier

  • local: Identifier (必填)
  • exported: Identifier (必填)

expressionStatement

t.expressionStatement(expression)

参见 t.isExpressionStatement(node, opts)t.assertExpressionStatement(node, opts)

别名: Statement, ExpressionWrapper

  • expression: Expression (必填)

file

t.file(program, comments, tokens)

参见 t.isFile(node, opts)t.assertFile(node, opts)

  • program: Program (必填)
  • comments (必填)
  • tokens (必填)

forAwaitStatement

t.forAwaitStatement(left, right, body)

参见 t.isForAwaitStatement(node, opts)t.assertForAwaitStatement(node, opts)

别名: Scopable, Statement, For, BlockParent, Loop, ForXStatement

  • left: VariableDeclaration | LVal (必填)
  • right: Expression (必填)
  • body: Statement (必填)

forInStatement

t.forInStatement(left, right, body)

参见 t.isForInStatement(node, opts)t.assertForInStatement(node, opts)

别名: Scopable, Statement, For, BlockParent, Loop, ForXStatement

  • left: VariableDeclaration | LVal (必填)
  • right: Expression (必填)
  • body: Statement (必填)

forOfStatement

t.forOfStatement(left, right, body)

参见 t.isForOfStatement(node, opts)t.assertForOfStatement(node, opts)

别名: Scopable, Statement, For, BlockParent, Loop, ForXStatement

  • left: VariableDeclaration | LVal (必填)
  • right: Expression (必填)
  • body: Statement (必填)

forStatement

t.forStatement(init, test, update, body)

参见 t.isForStatement(node, opts)t.assertForStatement(node, opts)

别名: Scopable, Statement, For, BlockParent, Loop

  • init: VariableDeclaration | Expression (默认为:null)
  • test: Expression (默认为:null)
  • update: Expression (默认为:null)
  • body: Statement (必填)

functionDeclaration

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

参见 t.isFunctionDeclaration(node, opts)t.assertFunctionDeclaration(node, opts)

别名: Scopable, Function, BlockParent, FunctionParent, Statement, Pureish, Declaration

  • id: Identifier (必填)
  • params: Array<LVal> (必填)
  • body: BlockStatement (必填)
  • generator: boolean (默认为:false)
  • async: boolean (默认为:false)
  • returnType (默认为:null)
  • typeParameters (默认为:null)

functionExpression

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

参见 t.isFunctionExpression(node, opts)t.assertFunctionExpression(node, opts)

别名: Scopable, Function, BlockParent, FunctionParent, Expression, Pureish

  • id: Identifier (默认为:null)
  • params: Array<LVal> (必填)
  • body: BlockStatement (必填)
  • generator: boolean (默认为:false)
  • async: boolean (默认为:false)
  • returnType (默认为:null)
  • typeParameters (默认为:null)

functionTypeAnnotation

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

参见 t.isFunctionTypeAnnotation(node, opts)t.assertFunctionTypeAnnotation(node, opts)

别名: Flow

  • typeParameters (必填)
  • params (必填)
  • rest (必填)
  • returnType (必填)

functionTypeParam

t.functionTypeParam(name, typeAnnotation)

参见 t.isFunctionTypeParam(node, opts)t.assertFunctionTypeParam(node, opts)

别名: Flow

  • name (必填)
  • typeAnnotation (必填)

genericTypeAnnotation

t.genericTypeAnnotation(id, typeParameters)

参见 t.isGenericTypeAnnotation(node, opts)t.assertGenericTypeAnnotation(node, opts)

别名: Flow

  • id (必填)
  • typeParameters (必填)

identifier

t.identifier(name)

参见 t.isIdentifier(node, opts)t.assertIdentifier(node, opts)

别名: Expression, LVal

  • namestring (必填)
  • decorators: Array<Decorator> (默认为:null)
  • typeAnnotation (默认为:null)

ifStatement

t.ifStatement(test, consequent, alternate)

参见 t.isIfStatement(node, opts)t.assertIfStatement(node, opts)

别名: Statement, Conditional

  • test: Expression (必填)
  • consequent: Statement (必填)
  • alternate: Statement (默认为:null)

import

t.import()

参见 t.isImport(node, opts)t.assertImport(node, opts)

别名: Expression


importDeclaration

t.importDeclaration(specifiers, source)

参见 t.isImportDeclaration(node, opts)t.assertImportDeclaration(node, opts)

别名: Statement, Declaration, ModuleDeclaration

  • specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier> (必填)
  • source: StringLiteral (必填)

importDefaultSpecifier

t.importDefaultSpecifier(local)

参见 t.isImportDefaultSpecifier(node, opts)t.assertImportDefaultSpecifier(node, opts)

别名: ModuleSpecifier

  • local: Identifier (必填)

importNamespaceSpecifier

t.importNamespaceSpecifier(local)

参见 t.isImportNamespaceSpecifier(node, opts)t.assertImportNamespaceSpecifier(node, opts)

别名: ModuleSpecifier

  • local: Identifier (必填)

importSpecifier

t.importSpecifier(local, imported)

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

别名: ModuleSpecifier

  • local: Identifier (必填)
  • imported: Identifier (必填)
  • importKind: null | 'type' | 'typeof' (默认为:null)

interfaceDeclaration

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

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

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)
  • typeParameters (必填)
  • extends (必填)
  • body (必填)

interfaceExtends

t.interfaceExtends(id, typeParameters)

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

别名: Flow

  • id (必填)
  • typeParameters (必填)

intersectionTypeAnnotation

t.intersectionTypeAnnotation(types)

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

别名: Flow

  • types (必填)

jSXAttribute

t.jSXAttribute(name, value)

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

别名: JSX, Immutable

  • name: JSXIdentifier | JSXNamespacedName (必填)
  • value: JSXElement | StringLiteral | JSXExpressionContainer (默认为:null)

jSXClosingElement

t.jSXClosingElement(name)

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

别名: JSX, Immutable

  • name: JSXIdentifier | JSXMemberExpression (必填)

jSXElement

t.jSXElement(openingElement, closingElement, children, selfClosing)

参见 t.isJSXElement(node, opts)t.assertJSXElement(node, opts)

别名: JSX, Immutable, Expression

  • openingElement: JSXOpeningElement (必填)
  • closingElement: JSXClosingElement (默认为:null)
  • children: Array<JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement> (必填)
  • selfClosing (必填)

jSXEmptyExpression

t.jSXEmptyExpression()

参见 t.isJSXEmptyExpression(node, opts)t.assertJSXEmptyExpression(node, opts)

别名: JSX, Expression


jSXExpressionContainer

t.jSXExpressionContainer(expression)

参见 t.isJSXExpressionContainer(node, opts)t.assertJSXExpressionContainer(node, opts)

别名: JSX, Immutable

  • expression: Expression (必填)

jSXIdentifier

t.jSXIdentifier(name)

参见 t.isJSXIdentifier(node, opts)t.assertJSXIdentifier(node, opts)

别名: JSX, Expression

  • name: string (必填)

jSXMemberExpression

t.jSXMemberExpression(object, property)

参见 t.isJSXMemberExpression(node, opts)t.assertJSXMemberExpression(node, opts)

别名: JSX, Expression

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

jSXNamespacedName

t.jSXNamespacedName(namespace, name)

参见 t.isJSXNamespacedName(node, opts)t.assertJSXNamespacedName(node, opts)

别名: JSX

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

jSXOpeningElement

t.jSXOpeningElement(name, attributes, selfClosing)

参见 t.isJSXOpeningElement(node, opts)t.assertJSXOpeningElement(node, opts)

别名: JSX, Immutable

  • name: JSXIdentifier | JSXMemberExpression (必填)
  • attributes: Array<JSXAttribute | JSXSpreadAttribute> (必填)
  • selfClosing: boolean (默认为:false)

jSXSpreadAttribute

t.jSXSpreadAttribute(argument)

参见 t.isJSXSpreadAttribute(node, opts)t.assertJSXSpreadAttribute(node, opts)

别名: JSX

  • argument: Expression (必填)

jSXSpreadChild

t.jSXSpreadChild(expression)

参见 t.isJSXSpreadChild(node, opts)t.assertJSXSpreadChild(node, opts)

别名: JSX, Immutable

  • expression: Expression (必填)

jSXText

t.jSXText(value)

参见 t.isJSXText(node, opts)t.assertJSXText(node, opts)

别名: JSX, Immutable

  • value: string (必填)

labeledStatement

t.labeledStatement(label, body)

参见 t.isLabeledStatement(node, opts)t.assertLabeledStatement(node, opts)

别名: Statement

  • label: Identifier (必填)
  • body: Statement (必填)

logicalExpression

t.logicalExpression(operator, left, right)

参见 t.isLogicalExpression(node, opts)t.assertLogicalExpression(node, opts)

别名: Binary, Expression

  • operator: '||' | '&&' (必填)
  • left: Expression (必填)
  • right: Expression (必填)

memberExpression

t.memberExpression(object, property, computed)

参见 t.isMemberExpression(node, opts)t.assertMemberExpression(node, opts)

别名: Expression, LVal

  • object: Expression (必填)
  • propertyif computed then Expression else Identifier (必填)
  • computed: boolean (默认为:false)

metaProperty

t.metaProperty(meta, property)

参见 t.isMetaProperty(node, opts)t.assertMetaProperty(node, opts)

别名: Expression

  • meta: string (必填)
  • property: string (必填)

mixedTypeAnnotation

t.mixedTypeAnnotation()

参见 t.isMixedTypeAnnotation(node, opts)t.assertMixedTypeAnnotation(node, opts)

别名: Flow, FlowBaseAnnotation


newExpression

t.newExpression(callee, arguments)

参见 t.isNewExpression(node, opts)t.assertNewExpression(node, opts)

别名: Expression

  • callee: Expression (必填)
  • arguments: Array<Expression | SpreadElement> (必填)

noop

t.noop()

参见 t.isNoop(node, opts)t.assertNoop(node, opts)


nullLiteral

t.nullLiteral()

参见 t.isNullLiteral(node, opts)t.assertNullLiteral(node, opts)

别名: Expression, Pureish, Literal, Immutable


nullLiteralTypeAnnotation

t.nullLiteralTypeAnnotation()

参见 t.isNullLiteralTypeAnnotation(node, opts)t.assertNullLiteralTypeAnnotation(node, opts)

别名: Flow, FlowBaseAnnotation


nullableTypeAnnotation

t.nullableTypeAnnotation(typeAnnotation)

参见 t.isNullableTypeAnnotation(node, opts)t.assertNullableTypeAnnotation(node, opts)

别名: Flow

  • typeAnnotation (必填)

numberTypeAnnotation

t.numberTypeAnnotation()

参见 t.isNumberTypeAnnotation(node, opts)t.assertNumberTypeAnnotation(node, opts)

别名: Flow, FlowBaseAnnotation


numericLiteral

t.numericLiteral(value)

参见 t.isNumericLiteral(node, opts)t.assertNumericLiteral(node, opts)

别名: Expression, Pureish, Literal, Immutable

  • value: number (必填)

numericLiteralTypeAnnotation

t.numericLiteralTypeAnnotation()

参见 t.isNumericLiteralTypeAnnotation(node, opts)t.assertNumericLiteralTypeAnnotation(node, opts)

别名: Flow


objectExpression

t.objectExpression(properties)

参见 t.isObjectExpression(node, opts)t.assertObjectExpression(node, opts)

别名: Expression

  • properties: Array<ObjectMethod | ObjectProperty | SpreadProperty> (必填)

objectMethod

t.objectMethod(kind, key, params, body, computed)

参见 t.isObjectMethod(node, opts)t.assertObjectMethod(node, opts)

别名: UserWhitespacable, Function, Scopable, BlockParent, FunctionParent, Method, ObjectMember

  • kind: "method" | "get" | "set" (默认为:'method')
  • keyif computed then Expression else Identifier | Literal (必填)
  • params (必填)
  • body: BlockStatement (必填)
  • computed: boolean (默认为:false)
  • async: boolean (默认为:false)
  • decorators: Array<Decorator> (默认为:null)
  • generator: boolean (默认为:false)
  • returnType (默认为:null)
  • typeParameters (默认为:null)

objectPattern

t.objectPattern(properties, typeAnnotation)

参见 t.isObjectPattern(node, opts)t.assertObjectPattern(node, opts)

别名: Pattern, LVal

  • properties: Array<RestProperty | Property> (必填)
  • typeAnnotation (必填)
  • decorators: Array<Decorator> (默认为:null)

objectProperty

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

参见 t.isObjectProperty(node, opts)t.assertObjectProperty(node, opts)

别名: UserWhitespacable, Property, ObjectMember

  • keyif computed then Expression else Identifier | Literal (必填)
  • value: Expression | Pattern | RestElement (必填)
  • computed: boolean (默认为:false)
  • shorthand: boolean (默认为:false)
  • decorators: Array<Decorator> (默认为:null)

objectTypeAnnotation

t.objectTypeAnnotation(properties, indexers, callProperties)

参见 t.isObjectTypeAnnotation(node, opts)t.assertObjectTypeAnnotation(node, opts)

别名: Flow

  • properties (必填)
  • indexers (必填)
  • callProperties (必填)

objectTypeCallProperty

t.objectTypeCallProperty(value)

参见 t.isObjectTypeCallProperty(node, opts)t.assertObjectTypeCallProperty(node, opts)

别名: Flow, UserWhitespacable

  • value (必填)

objectTypeIndexer

t.objectTypeIndexer(id, key, value)

参见 t.isObjectTypeIndexer(node, opts)t.assertObjectTypeIndexer(node, opts)

别名: Flow, UserWhitespacable

  • id (必填)
  • key (必填)
  • value (必填)

objectTypeProperty

t.objectTypeProperty(key, value)

参见 t.isObjectTypeProperty(node, opts)t.assertObjectTypeProperty(node, opts)

别名: Flow, UserWhitespacable

  • key (必填)
  • value (必填)

objectTypeSpreadProperty

t.objectTypeSpreadProperty(argument)

参见 t.isObjectTypeSpreadProperty(node, opts)t.assertObjectTypeSpreadProperty(node, opts)

别名: Flow, UserWhitespacable

  • argument (必填)

opaqueType

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

参见 t.isOpaqueType(node, opts)t.assertOpaqueType(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)
  • typeParameters (必填)
  • impltype (必填)
  • supertype (必填)

parenthesizedExpression

t.parenthesizedExpression(expression)

参见 t.isParenthesizedExpression(node, opts)t.assertParenthesizedExpression(node, opts)

别名: Expression, ExpressionWrapper

  • expression: Expression (必填)

program

t.program(body, directives)

参见 t.isProgram(node, opts)t.assertProgram(node, opts)

别名: Scopable, BlockParent, Block, FunctionParent

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

qualifiedTypeIdentifier

t.qualifiedTypeIdentifier(id, qualification)

参见 t.isQualifiedTypeIdentifier(node, opts)t.assertQualifiedTypeIdentifier(node, opts)

别名: Flow

  • id (必填)
  • qualification (必填)

regExpLiteral

t.regExpLiteral(pattern, flags)

参见 t.isRegExpLiteral(node, opts)t.assertRegExpLiteral(node, opts)

别名: Expression, Literal

  • pattern: string (必填)
  • flags: string (默认为:'')

restElement

t.restElement(argument, typeAnnotation)

参见 t.isRestElement(node, opts)t.assertRestElement(node, opts)

别名: LVal

  • argument: LVal (必填)
  • typeAnnotation (必填)
  • decorators: Array<Decorator> (默认为:null)

restProperty

t.restProperty(argument)

参见 t.isRestProperty(node, opts)t.assertRestProperty(node, opts)

别名: UnaryLike

  • argument: LVal (必填)

returnStatement

t.returnStatement(argument)

参见 t.isReturnStatement(node, opts)t.assertReturnStatement(node, opts)

别名: Statement, Terminatorless, CompletionStatement

  • argument: Expression (默认为:null)

sequenceExpression

t.sequenceExpression(expressions)

参见 t.isSequenceExpression(node, opts)t.assertSequenceExpression(node, opts)

别名: Expression

  • expressions: Array<Expression> (必填)

spreadElement

t.spreadElement(argument)

参见 t.isSpreadElement(node, opts)t.assertSpreadElement(node, opts)

别名: UnaryLike

  • argument: Expression (必填)

spreadProperty

t.spreadProperty(argument)

参见 t.isSpreadProperty(node, opts)t.assertSpreadProperty(node, opts)

别名: UnaryLike

  • argument: Expression (必填)

stringLiteral

t.stringLiteral(value)

参见 t.isStringLiteral(node, opts)t.assertStringLiteral(node, opts)

别名: Expression, Pureish, Literal, Immutable

  • value: string (必填)

stringLiteralTypeAnnotation

t.stringLiteralTypeAnnotation()

参见 t.isStringLiteralTypeAnnotation(node, opts)t.assertStringLiteralTypeAnnotation(node, opts)

别名: Flow


stringTypeAnnotation

t.stringTypeAnnotation()

参见 t.isStringTypeAnnotation(node, opts)t.assertStringTypeAnnotation(node, opts)

别名: Flow, FlowBaseAnnotation


super

t.super()

参见 t.isSuper(node, opts)t.assertSuper(node, opts)

别名: Expression


switchCase

t.switchCase(test, consequent)

参见 t.isSwitchCase(node, opts)t.assertSwitchCase(node, opts)

  • test: Expression (默认为:null)
  • consequent: Array<Statement> (必填)

switchStatement

t.switchStatement(discriminant, cases)

参见 t.isSwitchStatement(node, opts)t.assertSwitchStatement(node, opts)

别名: Statement, BlockParent, Scopable

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

taggedTemplateExpression

t.taggedTemplateExpression(tag, quasi)

参见 t.isTaggedTemplateExpression(node, opts)t.assertTaggedTemplateExpression(node, opts)

别名: Expression

  • tag: Expression (必填)
  • quasi: TemplateLiteral (必填)

templateElement

t.templateElement(value, tail)

参见 t.isTemplateElement(node, opts)t.assertTemplateElement(node, opts)

  • value (必填)
  • tail: boolean (默认为:false)

templateLiteral

t.templateLiteral(quasis, expressions)

参见 t.isTemplateLiteral(node, opts)t.assertTemplateLiteral(node, opts)

别名: Expression, Literal

  • quasis: Array<TemplateElement> (必填)
  • expressions: Array<Expression> (必填)

thisExpression

t.thisExpression()

参见 t.isThisExpression(node, opts)t.assertThisExpression(node, opts)

别名: Expression


thisTypeAnnotation

t.thisTypeAnnotation()

参见 t.isThisTypeAnnotation(node, opts)t.assertThisTypeAnnotation(node, opts)

别名: Flow, FlowBaseAnnotation


throwStatement

t.throwStatement(argument)

参见 t.isThrowStatement(node, opts)t.assertThrowStatement(node, opts)

别名: Statement, Terminatorless, CompletionStatement

  • argument: Expression (必填)

tryStatement

t.tryStatement(block, handler, finalizer)

参见 t.isTryStatement(node, opts)t.assertTryStatement(node, opts)

别名: Statement

  • block (必填)
  • handler (默认为:null)
  • finalizer: BlockStatement (默认为:null)
  • body: BlockStatement (默认为:null)

tupleTypeAnnotation

t.tupleTypeAnnotation(types)

参见 t.isTupleTypeAnnotation(node, opts)t.assertTupleTypeAnnotation(node, opts)

别名: Flow

  • types (必填)

typeAlias

t.typeAlias(id, typeParameters, right)

参见 t.isTypeAlias(node, opts)t.assertTypeAlias(node, opts)

别名: Flow, FlowDeclaration, Statement, Declaration

  • id (必填)
  • typeParameters (必填)
  • right (必填)

typeAnnotation

t.typeAnnotation(typeAnnotation)

参见 t.isTypeAnnotation(node, opts)t.assertTypeAnnotation(node, opts)

别名: Flow

  • typeAnnotation (必填)

typeCastExpression

t.typeCastExpression(expression, typeAnnotation)

参见 t.isTypeCastExpression(node, opts)t.assertTypeCastExpression(node, opts)

别名: Flow, ExpressionWrapper, Expression

  • expression (必填)
  • typeAnnotation (必填)

typeParameter

t.typeParameter(bound)

参见 t.isTypeParameter(node, opts)t.assertTypeParameter(node, opts)

别名: Flow

  • bound (必填)

typeParameterDeclaration

t.typeParameterDeclaration(params)

参见 t.isTypeParameterDeclaration(node, opts)t.assertTypeParameterDeclaration(node, opts)

别名: Flow

  • params (必填)

typeParameterInstantiation

t.typeParameterInstantiation(params)

参见 t.isTypeParameterInstantiation(node, opts)t.assertTypeParameterInstantiation(node, opts)

别名: Flow

  • params (必填)

typeofTypeAnnotation

t.typeofTypeAnnotation(argument)

参见 t.isTypeofTypeAnnotation(node, opts)t.assertTypeofTypeAnnotation(node, opts)

别名: Flow

  • argument (必填)

unaryExpression

t.unaryExpression(operator, argument, prefix)

参见 t.isUnaryExpression(node, opts)t.assertUnaryExpression(node, opts)

别名: UnaryLike, Expression

  • operator: 'void' | 'delete' | '!' | '+' | '-' | '++' | '--' | '~' | 'typeof' (必填)
  • argument: Expression (必填)
  • prefix: boolean (默认为:true)

unionTypeAnnotation

t.unionTypeAnnotation(types)

参见 t.isUnionTypeAnnotation(node, opts)t.assertUnionTypeAnnotation(node, opts)

别名: Flow

  • types (必填)

updateExpression

t.updateExpression(operator, argument, prefix)

参见 t.isUpdateExpression(node, opts)t.assertUpdateExpression(node, opts)

别名: Expression

  • operator: '++' | '--' (必填)
  • argument: Expression (必填)
  • prefix: boolean (默认为:false)

variableDeclaration

t.variableDeclaration(kind, declarations)

参见 t.isVariableDeclaration(node, opts)t.assertVariableDeclaration(node, opts)

别名: Statement, Declaration

  • kind: "var" | "let" | "const" (必填)
  • declarations: Array<VariableDeclarator> (必填)

—` 。

variableDeclarator

t.variableDeclarator(id, init)

参见 t.isVariableDeclarator(node, opts)t.assertVariableDeclarator(node, opts)

  • id: LVal (必填)
  • init: Expression (默认为:null)

voidTypeAnnotation

t.voidTypeAnnotation()

参见 t.isVoidTypeAnnotation(node, opts)t.assertVoidTypeAnnotation(node, opts)

别名: Flow, FlowBaseAnnotation


whileStatement

t.whileStatement(test, body)

参见 t.isWhileStatement(node, opts)t.assertWhileStatement(node, opts)

别名: Statement, BlockParent, Loop, While, Scopable

  • test: Expression (必填)
  • body: BlockStatement | Statement (必填)

withStatement

t.withStatement(object, body)

参见 t.isWithStatement(node, opts)t.assertWithStatement(node, opts)

别名: Statement

  • object (必填)
  • body: BlockStatement | Statement (必填)

yieldExpression

t.yieldExpression(argument, delegate)

参见 t.isYieldExpression(node, opts)t.assertYieldExpression(node, opts)

别名: Expression, Terminatorless

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