@babel/types by example

Disclamer

This is NOT the official documentation of @bable/types, just a nicer presentation of it. It can be outdated. If you're looking the official docs you can find them here.

This module contains methods for building ASTs manually and for checking the types of AST nodes.

Install

npm install --save-dev @babel/types

API

Node Builders

anyTypeAnnotation#

t.anyTypeAnnotation();
AnyTypeAnnotation

let name:any;

function foo(arg:any):any{
    //...
}

See also t.isAnyTypeAnnotation(node, opts) and t.assertAnyTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


argumentPlaceholder#

t.argumentPlaceholder();
ArgumentPlaceholder

See also t.isArgumentPlaceholder(node, opts) and t.assertArgumentPlaceholder(node, opts).


arrayExpression#

t.arrayExpression(elements);
ArrayExpression

let listOfNumbers = [2, 3, 5, 7, 11];

let day1 = {
  squirrel: false,
  events: ["work", "touched tree", "pizza", "running"]
};

const coord = [
  [0, 0],
  [76, 9],
  [4, 1]
];

var nested = [[[]]];

const [a, b] = [10, 20];

See also t.isArrayExpression(node, opts) and t.assertArrayExpression(node, opts).

AST Node ArrayExpression shape:

Aliases: Standardized, Expression


arrayPattern#

t.arrayPattern(elements);
ArrayPattern

const [a, b] = [10, 20];

function calc([isError, data]){
  // ...
}

let [info, ,...rest] = calculate();

var [x, [y, z]] = calculate();

See also t.isArrayPattern(node, opts) and t.assertArrayPattern(node, opts).

AST Node ArrayPattern shape:

  • elements: Array<null | PatternLike | LVal> (required)
  • decorators: Array<Decorator> (default: null, excluded from builder function)
  • optional: boolean (default: null, excluded from builder function)
  • typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop (default: null, excluded from builder function)

Aliases: Standardized, Pattern, PatternLike, LVal


arrayTypeAnnotation#

t.arrayTypeAnnotation(elementType);
ArrayTypeAnnotation

let elems: number[] = [2, 3, 4];

function foo(x: string[]){
	// ...
}

type Elem<T> = {x:T};

function calc(x: Elem<string>[]){
	// ...
}

let nums: number[][] = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]; 

See also t.isArrayTypeAnnotation(node, opts) and t.assertArrayTypeAnnotation(node, opts).

AST Node ArrayTypeAnnotation shape:

Aliases: Flow, FlowType


arrowFunctionExpression#

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

const materials = ['Hydrogen', 'Helium', 'Lithium', 'Beryllium'];

console.log(materials.map((material) => material.length));

() => expression;

param => expression;

(param) => expression;

(param1, paramN) => expression;

() => {
  // statements
}

param => {
  // statements
}

(param1, paramN) => {
  // statements
}

// async arrow functions

async param => expression;

async (param1, param2, ...paramN) => {
  statements
}

See also t.isArrowFunctionExpression(node, opts) and t.assertArrowFunctionExpression(node, opts).

AST Node ArrowFunctionExpression shape:

Aliases: Standardized, Scopable, Function, BlockParent, FunctionParent, Expression, Pureish


assignmentExpression#

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

const x = y = 5;

while( (elem = elem.next()) ){
	// ...
}

See also t.isAssignmentExpression(node, opts) and t.assertAssignmentExpression(node, opts).

AST Node AssignmentExpression shape:

Aliases: Standardized, Expression


assignmentPattern#

t.assignmentPattern(left, right);
AssignmentPattern

function calc(x = 1000, y=50, z){
  // ..
}

See also t.isAssignmentPattern(node, opts) and t.assertAssignmentPattern(node, opts).

AST Node AssignmentPattern shape:

Aliases: Standardized, Pattern, PatternLike, LVal


awaitExpression#

t.awaitExpression(argument);
AwaitExpression

const fetchUsers = async () => {
  const resp = await fetch('https://example.com/users');
  users = resp.json();
}

await fetchUsers();

See also t.isAwaitExpression(node, opts) and t.assertAwaitExpression(node, opts).

AST Node AwaitExpression shape:

Aliases: Standardized, Expression, Terminatorless


bigIntLiteral#

t.bigIntLiteral(value);
BigIntLiteral

const a = 1n + 2n; // 3n

const b = 1n / 2n; // 0n

const c = 40000000000000000n >> 2n; // 10000000000000000n

See also t.isBigIntLiteral(node, opts) and t.assertBigIntLiteral(node, opts).

AST Node BigIntLiteral shape:

  • value: string (required)

Aliases: Standardized, Expression, Pureish, Literal, Immutable


binaryExpression#

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

const num = 2 ** 3;

function add10(x){
    return x + 10;
}

let str = 'a' + 'b';

See also t.isBinaryExpression(node, opts) and t.assertBinaryExpression(node, opts).

AST Node BinaryExpression shape:

  • operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>" (required)
  • left: Expression | PrivateName (required)
  • right: Expression (required)

Aliases: Standardized, Binary, Expression


bindExpression#

t.bindExpression(object, callee);
BindExpression

import { map, takeWhile, forEach } from "iterlib";

getPlayers()
  ::map(x => x.character())
  ::takeWhile(x => x.strength > 100)
  ::forEach(x => console.log(x));


Promise.resolve(123).then(::console.log);

See also t.isBindExpression(node, opts) and t.assertBindExpression(node, opts).

AST Node BindExpression shape:

Aliases: Expression


blockStatement#

t.blockStatement(body, directives);
BlockStatement

let x = 1;
{
  let x = 2;
}
console.log(x); // 1

function foo(log) {
  if(log) {
    console.log("foo");
  }
}

for (let i = 0; i < 10; i++) {
  console.log(i);
}

See also t.isBlockStatement(node, opts) and t.assertBlockStatement(node, opts).

AST Node BlockStatement shape:

Aliases: Standardized, Scopable, BlockParent, Block, Statement


booleanLiteral#

t.booleanLiteral(value);
BooleanLiteral

if(true) {
	console.log("Yes");
}

let nop = false;

let i=0;

while(true) {
  i++;
  if(i>10){
    break;
  }
}

See also t.isBooleanLiteral(node, opts) and t.assertBooleanLiteral(node, opts).

AST Node BooleanLiteral shape:

  • value: boolean (required)

Aliases: Standardized, Expression, Pureish, Literal, Immutable


booleanLiteralTypeAnnotation#

t.booleanLiteralTypeAnnotation(value);
BooleanLiteralTypeAnnotation

See also t.isBooleanLiteralTypeAnnotation(node, opts) and t.assertBooleanLiteralTypeAnnotation(node, opts).

AST Node BooleanLiteralTypeAnnotation shape:

  • value: boolean (required)

Aliases: Flow, FlowType


booleanTypeAnnotation#

t.booleanTypeAnnotation();
BooleanTypeAnnotation

See also t.isBooleanTypeAnnotation(node, opts) and t.assertBooleanTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


breakStatement#

t.breakStatement(label);
BreakStatement

const expr = 'Papayas';
switch (expr) {
  case 'Oranges':
    console.log('Oranges are $0.59 a pound.');
    break;
  case 'Mangoes':
  case 'Papayas':
    console.log('Mangoes and papayas are $2.79 a pound.');
    // Expected output: "Mangoes and papayas are $2.79 a pound."
    break;
  default:
    console.log(`Sorry, we are out of ${expr}.`);
}

// 

let i=0, j=10;

topLoop: while(true){
    i+=2;
    while(true) {
        j+=1
        if(i>j){
        	break topLoop;
        }
    }
}

See also t.isBreakStatement(node, opts) and t.assertBreakStatement(node, opts).

AST Node BreakStatement shape:

Aliases: Standardized, Statement, Terminatorless, CompletionStatement


callExpression#

t.callExpression(callee, arguments);
CallExpression

const n = parseInt("22");

function foo() {
  //
}

foo();

(() => {
  let i = 0;
  console.log(i);
})();

See also t.isCallExpression(node, opts) and t.assertCallExpression(node, opts).

AST Node CallExpression shape:

Aliases: Standardized, Expression


catchClause#

t.catchClause(param, body);
CatchClause

try {
	const foo = bar();
} catch {
    console.err('Oops');
}

try {
	const foo = bar();
} catch (e) {
	console.log(e);
} finally{
    console.log('end');
}

See also t.isCatchClause(node, opts) and t.assertCatchClause(node, opts).

AST Node CatchClause shape:

Aliases: Standardized, Scopable, BlockParent


classAccessorProperty#

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

See also t.isClassAccessorProperty(node, opts) and t.assertClassAccessorProperty(node, opts).

AST Node ClassAccessorProperty shape:

  • key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression | PrivateName (required)
  • value: Expression (default: null)
  • typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop (default: null)
  • decorators: Array<Decorator> (default: null)
  • computed: boolean (default: false)
  • static: boolean (default: false)
  • abstract: boolean (default: null, excluded from builder function)
  • accessibility: "public" | "private" | "protected" (default: null, excluded from builder function)
  • declare: boolean (default: null, excluded from builder function)
  • definite: boolean (default: null, excluded from builder function)
  • optional: boolean (default: null, excluded from builder function)
  • override: boolean (default: false, excluded from builder function)
  • readonly: boolean (default: null, excluded from builder function)
  • variance: Variance (default: null, excluded from builder function)

Aliases: Standardized, Property, Accessor


classBody#

t.classBody(body);
ClassBody

class Klass {
  
  #a=3
  
  #foo() {
    //..
  }
  
  b=4
  
  bar() {
    //...
  }
}

See also t.isClassBody(node, opts) and t.assertClassBody(node, opts).

AST Node ClassBody shape:

Aliases: Standardized


classDeclaration#

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

class Klass {
  
  #a=3
  
  #foo() {
    //..
  }
  
  b=4
  
  bar() {
    //...
  }
}

See also t.isClassDeclaration(node, opts) and t.assertClassDeclaration(node, opts).

AST Node ClassDeclaration shape:

Aliases: Standardized, Scopable, Class, Statement, Declaration


classExpression#

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


const P = class K {
  // ..
}

See also t.isClassExpression(node, opts) and t.assertClassExpression(node, opts).

AST Node ClassExpression shape:

Aliases: Standardized, Scopable, Class, Expression


classImplements#

t.classImplements(id, typeParameters);
ClassImplements

interface Serializable {
  serialize(): string;
}

class Element implements Serializable {
  serialize(): string { return '[Element]'; }
}

class Foo implements
  Bar,
  Baz {
  // ...
}

See also t.isClassImplements(node, opts) and t.assertClassImplements(node, opts).

AST Node ClassImplements shape:

Aliases: Flow


classMethod#

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

class Klass {
  
  #a=3
  
  #foo() {
    //..
  }
  
  b=4
  
  bar() {
    //...
  }
}

See also t.isClassMethod(node, opts) and t.assertClassMethod(node, opts).

AST Node ClassMethod shape:

  • kind: "get" | "set" | "method" | "constructor" (default: 'method')
  • key: if computed then Expression else Identifier | Literal (required)
  • params: Array<Identifier | Pattern | RestElement | TSParameterProperty> (required)
  • body: BlockStatement (required)
  • computed: boolean (default: false)
  • static: boolean (default: false)
  • generator: boolean (default: false)
  • async: boolean (default: false)
  • abstract: boolean (default: null, excluded from builder function)
  • access: "public" | "private" | "protected" (default: null, excluded from builder function)
  • accessibility: "public" | "private" | "protected" (default: null, excluded from builder function)
  • decorators: Array<Decorator> (default: null, excluded from builder function)
  • optional: boolean (default: null, excluded from builder function)
  • override: boolean (default: false, excluded from builder function)
  • returnType: TypeAnnotation | TSTypeAnnotation | Noop (default: null, excluded from builder function)
  • typeParameters: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop (default: null, excluded from builder function)

Aliases: Standardized, Function, Scopable, BlockParent, FunctionParent, Method


classPrivateMethod#

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

class Klass {
  
  #a=3
  
  #foo() {
    //..
  }
  
  b=4
  
  bar() {
    //...
  }
}

See also t.isClassPrivateMethod(node, opts) and t.assertClassPrivateMethod(node, opts).

AST Node ClassPrivateMethod shape:

  • kind: "get" | "set" | "method" (default: 'method')
  • key: PrivateName (required)
  • params: Array<Identifier | Pattern | RestElement | TSParameterProperty> (required)
  • body: BlockStatement (required)
  • static: boolean (default: false)
  • abstract: boolean (default: null, excluded from builder function)
  • access: "public" | "private" | "protected" (default: null, excluded from builder function)
  • accessibility: "public" | "private" | "protected" (default: null, excluded from builder function)
  • async: boolean (default: false, excluded from builder function)
  • computed: 'false' (default: false, excluded from builder function)
  • decorators: Array<Decorator> (default: null, excluded from builder function)
  • generator: boolean (default: false, excluded from builder function)
  • optional: boolean (default: null, excluded from builder function)
  • override: boolean (default: false, excluded from builder function)
  • returnType: TypeAnnotation | TSTypeAnnotation | Noop (default: null, excluded from builder function)
  • typeParameters: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop (default: null, excluded from builder function)

Aliases: Standardized, Function, Scopable, BlockParent, FunctionParent, Method, Private


classPrivateProperty#

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

class Klass {
  
  #a=3
  
  #foo() {
    //..
  }
  
  b=4
  
  bar() {
    //...
  }
}

See also t.isClassPrivateProperty(node, opts) and t.assertClassPrivateProperty(node, opts).

AST Node ClassPrivateProperty shape:

  • key: PrivateName (required)
  • value: Expression (default: null)
  • decorators: Array<Decorator> (default: null)
  • static: boolean (default: false)
  • definite: boolean (default: null, excluded from builder function)
  • readonly: boolean (default: null, excluded from builder function)
  • typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop (default: null, excluded from builder function)
  • variance: Variance (default: null, excluded from builder function)

Aliases: Standardized, Property, Private


classProperty#

t.classProperty(key, value, typeAnnotation, decorators, computed, static);
ClassProperty

class Klass {
  
  #a=3
  
  #foo() {
    //..
  }
  
  b=4
  
  bar() {
    //...
  }
}
History

| Version | Changes | | --- | --- | | v7.6.0 | Supports static |

See also t.isClassProperty(node, opts) and t.assertClassProperty(node, opts).

AST Node ClassProperty shape:

  • key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression (required)
  • value: Expression (default: null)
  • typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop (default: null)
  • decorators: Array<Decorator> (default: null)
  • computed: boolean (default: false)
  • static: boolean (default: false)
  • abstract: boolean (default: null, excluded from builder function)
  • accessibility: "public" | "private" | "protected" (default: null, excluded from builder function)
  • declare: boolean (default: null, excluded from builder function)
  • definite: boolean (default: null, excluded from builder function)
  • optional: boolean (default: null, excluded from builder function)
  • override: boolean (default: false, excluded from builder function)
  • readonly: boolean (default: null, excluded from builder function)
  • variance: Variance (default: null, excluded from builder function)

Aliases: Standardized, Property


conditionalExpression#

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

function getFee(isMember) {
  return isMember ? '$2.00' : '$10.00';
}

console.log(getFee(true));

See also t.isConditionalExpression(node, opts) and t.assertConditionalExpression(node, opts).

AST Node ConditionalExpression shape:

Aliases: Standardized, Expression, Conditional


continueStatement#

t.continueStatement(label);
ContinueStatement

let text = '';

for (let i = 0; i < 10; i++) {
  if (i === 3) {
    continue;
  }
  text = text + i;
}

console.log(text);
// Expected output: "012456789"

See also t.isContinueStatement(node, opts) and t.assertContinueStatement(node, opts).

AST Node ContinueStatement shape:

Aliases: Standardized, Statement, Terminatorless, CompletionStatement


debuggerStatement#

t.debuggerStatement();
DebuggerStatement

function potentiallyBuggyCode() {
  debugger;
  // do potentially buggy stuff to examine, step through, etc.
}

See also t.isDebuggerStatement(node, opts) and t.assertDebuggerStatement(node, opts).

Aliases: Standardized, Statement


decimalLiteral#

t.decimalLiteral(value);
DecimalLiteral

const decimal = 100m;
const bigInt = 100n;
const numeric =100;

0.1999999991m;

0.1m + 0.2m === 0.3m; // -> true

See also t.isDecimalLiteral(node, opts) and t.assertDecimalLiteral(node, opts).

AST Node DecimalLiteral shape:

  • value: string (required)

Aliases: Expression, Pureish, Literal, Immutable


declareClass#

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

See also t.isDeclareClass(node, opts) and t.assertDeclareClass(node, opts).

AST Node DeclareClass shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


declareExportAllDeclaration#

t.declareExportAllDeclaration(source);
DeclareExportAllDeclaration

See also t.isDeclareExportAllDeclaration(node, opts) and t.assertDeclareExportAllDeclaration(node, opts).

AST Node DeclareExportAllDeclaration shape:

  • source: StringLiteral (required)
  • exportKind: "type" | "value" (default: null, excluded from builder function)

Aliases: Flow, FlowDeclaration, Statement, Declaration


declareExportDeclaration#

t.declareExportDeclaration(declaration, specifiers, source);
DeclareExportDeclaration

See also t.isDeclareExportDeclaration(node, opts) and t.assertDeclareExportDeclaration(node, opts).

AST Node DeclareExportDeclaration shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


declareFunction#

t.declareFunction(id);
DeclareFunction

See also t.isDeclareFunction(node, opts) and t.assertDeclareFunction(node, opts).

AST Node DeclareFunction shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


declareInterface#

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

See also t.isDeclareInterface(node, opts) and t.assertDeclareInterface(node, opts).

AST Node DeclareInterface shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


declareModule#

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

See also t.isDeclareModule(node, opts) and t.assertDeclareModule(node, opts).

AST Node DeclareModule shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


declareModuleExports#

t.declareModuleExports(typeAnnotation);
DeclareModuleExports

See also t.isDeclareModuleExports(node, opts) and t.assertDeclareModuleExports(node, opts).

AST Node DeclareModuleExports shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


declareOpaqueType#

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

See also t.isDeclareOpaqueType(node, opts) and t.assertDeclareOpaqueType(node, opts).

AST Node DeclareOpaqueType shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


declareTypeAlias#

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

See also t.isDeclareTypeAlias(node, opts) and t.assertDeclareTypeAlias(node, opts).

AST Node DeclareTypeAlias shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


declareVariable#

t.declareVariable(id);
DeclareVariable

See also t.isDeclareVariable(node, opts) and t.assertDeclareVariable(node, opts).

AST Node DeclareVariable shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


declaredPredicate#

t.declaredPredicate(value);
DeclaredPredicate

See also t.isDeclaredPredicate(node, opts) and t.assertDeclaredPredicate(node, opts).

AST Node DeclaredPredicate shape:

  • value: Flow (required)

Aliases: Flow, FlowPredicate


decorator#

t.decorator(expression);
Decorator

@ClassLogger()
class X {
  
  @PropertyLogger
  prop=1
  
  @MethodLogger
  method() {
  }
}

See also t.isDecorator(node, opts) and t.assertDecorator(node, opts).

AST Node Decorator shape:


directive#

t.directive(value);
Directive

"use strict";

//

"use server";

//

"use client";

See also t.isDirective(node, opts) and t.assertDirective(node, opts).

AST Node Directive shape:

Aliases: Standardized


directiveLiteral#

t.directiveLiteral(value);
DirectiveLiteral

"use strict";

See also t.isDirectiveLiteral(node, opts) and t.assertDirectiveLiteral(node, opts).

AST Node DirectiveLiteral shape:

  • value: string (required)

Aliases: Standardized


doExpression#

t.doExpression(body, async);
DoExpression

let x = do {
  let tmp = f();
  tmp * tmp + 1
};


const Nav = () => {
  return (
    <nav>
      <Home />
      {
        do {
          if (loggedIn) {
            <LogoutButton />
          } else {
            <LoginButton />
          }
        }
      }
    </nav>
  );
}

See also t.isDoExpression(node, opts) and t.assertDoExpression(node, opts).

AST Node DoExpression shape:

Aliases: Expression


doWhileStatement#

t.doWhileStatement(test, body);
DoWhileStatement

let i=0;

do {
  i++;
} while(i<10);

See also t.isDoWhileStatement(node, opts) and t.assertDoWhileStatement(node, opts).

AST Node DoWhileStatement shape:

Aliases: Standardized, Statement, BlockParent, Loop, While, Scopable


emptyStatement#

t.emptyStatement();
EmptyStatement


;

See also t.isEmptyStatement(node, opts) and t.assertEmptyStatement(node, opts).

Aliases: Standardized, Statement


emptyTypeAnnotation#

t.emptyTypeAnnotation();
EmptyTypeAnnotation

See also t.isEmptyTypeAnnotation(node, opts) and t.assertEmptyTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


enumBooleanBody#

t.enumBooleanBody(members);
EnumBooleanBody

See also t.isEnumBooleanBody(node, opts) and t.assertEnumBooleanBody(node, opts).

AST Node EnumBooleanBody shape:

  • members: Array<EnumBooleanMember> (required)
  • explicitType: boolean (required)
  • hasUnknownMembers: boolean (required)

Aliases: Flow, EnumBody


enumBooleanMember#

t.enumBooleanMember(id);
EnumBooleanMember

See also t.isEnumBooleanMember(node, opts) and t.assertEnumBooleanMember(node, opts).

AST Node EnumBooleanMember shape:

Aliases: Flow, EnumMember


enumDeclaration#

t.enumDeclaration(id, body);
EnumDeclaration

See also t.isEnumDeclaration(node, opts) and t.assertEnumDeclaration(node, opts).

AST Node EnumDeclaration shape:

Aliases: Flow, Statement, Declaration


enumDefaultedMember#

t.enumDefaultedMember(id);
EnumDefaultedMember

See also t.isEnumDefaultedMember(node, opts) and t.assertEnumDefaultedMember(node, opts).

AST Node EnumDefaultedMember shape:

Aliases: Flow, EnumMember


enumNumberBody#

t.enumNumberBody(members);
EnumNumberBody

See also t.isEnumNumberBody(node, opts) and t.assertEnumNumberBody(node, opts).

AST Node EnumNumberBody shape:

  • members: Array<EnumNumberMember> (required)
  • explicitType: boolean (required)
  • hasUnknownMembers: boolean (required)

Aliases: Flow, EnumBody


enumNumberMember#

t.enumNumberMember(id, init);
EnumNumberMember

See also t.isEnumNumberMember(node, opts) and t.assertEnumNumberMember(node, opts).

AST Node EnumNumberMember shape:

Aliases: Flow, EnumMember


enumStringBody#

t.enumStringBody(members);
EnumStringBody

See also t.isEnumStringBody(node, opts) and t.assertEnumStringBody(node, opts).

AST Node EnumStringBody shape:

Aliases: Flow, EnumBody


enumStringMember#

t.enumStringMember(id, init);
EnumStringMember

See also t.isEnumStringMember(node, opts) and t.assertEnumStringMember(node, opts).

AST Node EnumStringMember shape:

Aliases: Flow, EnumMember


enumSymbolBody#

t.enumSymbolBody(members);
EnumSymbolBody

See also t.isEnumSymbolBody(node, opts) and t.assertEnumSymbolBody(node, opts).

AST Node EnumSymbolBody shape:

Aliases: Flow, EnumBody


existsTypeAnnotation#

t.existsTypeAnnotation();
ExistsTypeAnnotation

See also t.isExistsTypeAnnotation(node, opts) and t.assertExistsTypeAnnotation(node, opts).

Aliases: Flow, FlowType


exportAllDeclaration#

t.exportAllDeclaration(source);
ExportAllDeclaration

See also t.isExportAllDeclaration(node, opts) and t.assertExportAllDeclaration(node, opts).

AST Node ExportAllDeclaration shape:

  • source: StringLiteral (required)
  • assertions: Array<ImportAttribute> (default: null, excluded from builder function)
  • attributes: Array<ImportAttribute> (default: null, excluded from builder function)
  • exportKind: "type" | "value" (default: null, excluded from builder function)

Aliases: Standardized, Statement, Declaration, ImportOrExportDeclaration, ExportDeclaration


exportDefaultDeclaration#

t.exportDefaultDeclaration(declaration);
ExportDefaultDeclaration

export const data = [/*...*/];

export function foo () {
	// ...
}

export default Lib;

See also t.isExportDefaultDeclaration(node, opts) and t.assertExportDefaultDeclaration(node, opts).

AST Node ExportDefaultDeclaration shape:

Aliases: Standardized, Statement, Declaration, ImportOrExportDeclaration, ExportDeclaration


exportDefaultSpecifier#

t.exportDefaultSpecifier(exported);
ExportDefaultSpecifier

export default copyArray;

See also t.isExportDefaultSpecifier(node, opts) and t.assertExportDefaultSpecifier(node, opts).

AST Node ExportDefaultSpecifier shape:

Aliases: ModuleSpecifier


exportNamedDeclaration#

t.exportNamedDeclaration(declaration, specifiers, source);
ExportNamedDeclaration

export { copyObject };

See also t.isExportNamedDeclaration(node, opts) and t.assertExportNamedDeclaration(node, opts).

AST Node ExportNamedDeclaration shape:

Aliases: Standardized, Statement, Declaration, ImportOrExportDeclaration, ExportDeclaration


exportNamespaceSpecifier#

t.exportNamespaceSpecifier(exported);
ExportNamespaceSpecifier

See also t.isExportNamespaceSpecifier(node, opts) and t.assertExportNamespaceSpecifier(node, opts).

AST Node ExportNamespaceSpecifier shape:

Aliases: Standardized, ModuleSpecifier


exportSpecifier#

t.exportSpecifier(local, exported);
ExportSpecifier

export { copyObject, copyArray };

See also t.isExportSpecifier(node, opts) and t.assertExportSpecifier(node, opts).

AST Node ExportSpecifier shape:

Aliases: Standardized, ModuleSpecifier


expressionStatement#

t.expressionStatement(expression);
ExpressionStatement

(function foo() {
  console.log("foo");
})();


let x = [1, 2, 3];
x[0] = 4;

const y = {
  foo: 1,
  bar: 2,
};

See also t.isExpressionStatement(node, opts) and t.assertExpressionStatement(node, opts).

AST Node ExpressionStatement shape:

Aliases: Standardized, Statement, ExpressionWrapper


file#

t.file(program, comments, tokens);
File

// File is the top level node
// containing only Program node in "program" field
// and "comments" field being an array with all comments.

See also t.isFile(node, opts) and t.assertFile(node, opts).

AST Node File shape:

Aliases: Standardized


forInStatement#

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

const object = { a: 1, b: 2, c: 3 };

for (const property in object) {
  console.log(`${property}: ${object[property]}`);
}

See also t.isForInStatement(node, opts) and t.assertForInStatement(node, opts).

AST Node ForInStatement shape:

Aliases: Standardized, Scopable, Statement, For, BlockParent, Loop, ForXStatement


forOfStatement#

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

const array1 = ['a', 'b', 'c'];

for (const element of array1) {
  console.log(element);
}

//

async function* foo() {
  yield 1;
  yield 2;
}

for await (const num of foo()) {
  console.log(num);
}

See also t.isForOfStatement(node, opts) and t.assertForOfStatement(node, opts).

AST Node ForOfStatement shape:

Aliases: Standardized, Scopable, Statement, For, BlockParent, Loop, ForXStatement


forStatement#

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

let i = 0;
for (; i < 9; i++) {
  console.log(i);
}

See also t.isForStatement(node, opts) and t.assertForStatement(node, opts).

AST Node ForStatement shape:

Aliases: Standardized, Scopable, Statement, For, BlockParent, Loop


functionDeclaration#

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

function* generator(i) {
  yield i;
  yield i + 10;
}

const gen = generator(10);

console.log(gen.next().value);
// Expected output: 10

function calcRectArea(width, height) {
  return width * height;
}

console.log(calcRectArea(5, 6));

See also t.isFunctionDeclaration(node, opts) and t.assertFunctionDeclaration(node, opts).

AST Node FunctionDeclaration shape:

Aliases: Standardized, Scopable, Function, BlockParent, FunctionParent, Statement, Pureish, Declaration


functionExpression#

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

const getRectArea = function (width, height) {
  return width * height;
};

console.log(getRectArea(3, 4));

See also t.isFunctionExpression(node, opts) and t.assertFunctionExpression(node, opts).

AST Node FunctionExpression shape:

Aliases: Standardized, Scopable, Function, BlockParent, FunctionParent, Expression, Pureish


functionTypeAnnotation#

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

See also t.isFunctionTypeAnnotation(node, opts) and t.assertFunctionTypeAnnotation(node, opts).

AST Node FunctionTypeAnnotation shape:

Aliases: Flow, FlowType


functionTypeParam#

t.functionTypeParam(name, typeAnnotation);
FunctionTypeParam

See also t.isFunctionTypeParam(node, opts) and t.assertFunctionTypeParam(node, opts).

AST Node FunctionTypeParam shape:

  • name: Identifier (default: null)
  • typeAnnotation: FlowType (required)
  • optional: boolean (default: null, excluded from builder function)

Aliases: Flow


genericTypeAnnotation#

t.genericTypeAnnotation(id, typeParameters);
GenericTypeAnnotation

See also t.isGenericTypeAnnotation(node, opts) and t.assertGenericTypeAnnotation(node, opts).

AST Node GenericTypeAnnotation shape:

Aliases: Flow, FlowType


identifier#

t.identifier(name);
Identifier

var foo='lorem ipsum dolor sit amet';

`a ${b} c`

See also t.isIdentifier(node, opts) and t.assertIdentifier(node, opts).

AST Node Identifier shape:

  • name: string (required)
  • decorators: Array<Decorator> (default: null, excluded from builder function)
  • optional: boolean (default: null, excluded from builder function)
  • typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop (default: null, excluded from builder function)

Aliases: Standardized, Expression, PatternLike, LVal, TSEntityName


ifStatement#

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

function testNum(a) {
  let result;
  if (a > 0) {
    result = 'positive';
  } else {
    result = 'NOT positive';
  }
  return result;
}

console.log(testNum(-5));
// Expected output: "NOT positive"

See also t.isIfStatement(node, opts) and t.assertIfStatement(node, opts).

AST Node IfStatement shape:

Aliases: Standardized, Statement, Conditional


import#

t.import();
Import

See also t.isImport(node, opts) and t.assertImport(node, opts).

Aliases: Standardized, Expression


importAttribute#

t.importAttribute(key, value);
ImportAttribute

import 'data:text/javascript,console.log("hello!");';
import _ from 'data:application/json,"world!"' with { type: 'json' }; 

See also t.isImportAttribute(node, opts) and t.assertImportAttribute(node, opts).

AST Node ImportAttribute shape:


importDeclaration#

t.importDeclaration(specifiers, source);
ImportDeclaration

History

| Version | Changes | | --- | --- | | v7.20.0 | Supports module |

See also t.isImportDeclaration(node, opts) and t.assertImportDeclaration(node, opts).

AST Node ImportDeclaration shape:

  • specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier> (required)
  • source: StringLiteral (required)
  • assertions: Array<ImportAttribute> (default: null, excluded from builder function)
  • attributes: Array<ImportAttribute> (default: null, excluded from builder function)
  • importKind: "type" | "typeof" | "value" (default: null, excluded from builder function)
  • module: boolean (default: null, excluded from builder function)
  • phase: "source" | "defer" (default: null, excluded from builder function)

Aliases: Standardized, Statement, Declaration, ImportOrExportDeclaration


importDefaultSpecifier#

t.importDefaultSpecifier(local);
ImportDefaultSpecifier

See also t.isImportDefaultSpecifier(node, opts) and t.assertImportDefaultSpecifier(node, opts).

AST Node ImportDefaultSpecifier shape:

Aliases: Standardized, ModuleSpecifier


importExpression#

t.importExpression(source, options);
ImportExpression

See also t.isImportExpression(node, opts) and t.assertImportExpression(node, opts).

AST Node ImportExpression shape:

  • source: Expression (required)
  • options: Expression (default: null)
  • phase: "source" | "defer" (default: null, excluded from builder function)

Aliases: Standardized, Expression


importNamespaceSpecifier#

t.importNamespaceSpecifier(local);
ImportNamespaceSpecifier

import * as localname from "module-name";

See also t.isImportNamespaceSpecifier(node, opts) and t.assertImportNamespaceSpecifier(node, opts).

AST Node ImportNamespaceSpecifier shape:

Aliases: Standardized, ModuleSpecifier


importSpecifier#

t.importSpecifier(local, imported);
ImportSpecifier

See also t.isImportSpecifier(node, opts) and t.assertImportSpecifier(node, opts).

AST Node ImportSpecifier shape:

  • local: Identifier (required)
  • imported: Identifier | StringLiteral (required)
  • importKind: "type" | "typeof" | "value" (default: null, excluded from builder function)

Aliases: Standardized, ModuleSpecifier


indexedAccessType#

t.indexedAccessType(objectType, indexType);
IndexedAccessType

See also t.isIndexedAccessType(node, opts) and t.assertIndexedAccessType(node, opts).

AST Node IndexedAccessType shape:

Aliases: Flow, FlowType


inferredPredicate#

t.inferredPredicate();
InferredPredicate

See also t.isInferredPredicate(node, opts) and t.assertInferredPredicate(node, opts).

Aliases: Flow, FlowPredicate


interfaceDeclaration#

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

See also t.isInterfaceDeclaration(node, opts) and t.assertInterfaceDeclaration(node, opts).

AST Node InterfaceDeclaration shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


interfaceExtends#

t.interfaceExtends(id, typeParameters);
InterfaceExtends

See also t.isInterfaceExtends(node, opts) and t.assertInterfaceExtends(node, opts).

AST Node InterfaceExtends shape:

Aliases: Flow


interfaceTypeAnnotation#

t.interfaceTypeAnnotation(extends, body);
InterfaceTypeAnnotation

See also t.isInterfaceTypeAnnotation(node, opts) and t.assertInterfaceTypeAnnotation(node, opts).

AST Node InterfaceTypeAnnotation shape:

Aliases: Flow, FlowType


interpreterDirective#

t.interpreterDirective(value);
InterpreterDirective

See also t.isInterpreterDirective(node, opts) and t.assertInterpreterDirective(node, opts).

AST Node InterpreterDirective shape:

  • value: string (required)

Aliases: Standardized


intersectionTypeAnnotation#

t.intersectionTypeAnnotation(types);
IntersectionTypeAnnotation

See also t.isIntersectionTypeAnnotation(node, opts) and t.assertIntersectionTypeAnnotation(node, opts).

AST Node IntersectionTypeAnnotation shape:

Aliases: Flow, FlowType


jsxAttribute#

t.jsxAttribute(name, value);
JSXAttribute

const Button = () => {
  return <button size="sm" textColor="white" bgColor="blue-500">
    Enable
  </button>;
};

See also t.isJSXAttribute(node, opts) and t.assertJSXAttribute(node, opts).

AST Node JSXAttribute shape:

Aliases: JSX, Immutable


jsxClosingElement#

t.jsxClosingElement(name);
JSXClosingElement

const Button = () => {
  return <button size="sm" textColor="white" bgColor="blue-500">
    Enable
  </button>;
};

See also t.isJSXClosingElement(node, opts) and t.assertJSXClosingElement(node, opts).

AST Node JSXClosingElement shape:

Aliases: JSX, Immutable


jsxClosingFragment#

t.jsxClosingFragment();
JSXClosingFragment

const TableData = () => {
  return (
    <>
      <td>John Doe</td>
      <td>36</td>
      <td>Developer</td>;
    </>
  );
}

See also t.isJSXClosingFragment(node, opts) and t.assertJSXClosingFragment(node, opts).

Aliases: JSX, Immutable


jsxElement#

t.jsxElement(openingElement, closingElement, children, selfClosing);
JSXElement

const Button = () => {
  return <button size="sm" textColor="white" bgColor="blue-500">
    Enable
  </button>;
};

See also t.isJSXElement(node, opts) and t.assertJSXElement(node, opts).

AST Node JSXElement shape:

Aliases: JSX, Immutable, Expression


jsxEmptyExpression#

t.jsxEmptyExpression();
JSXEmptyExpression

const Link = () => <a>{ }</a>;

See also t.isJSXEmptyExpression(node, opts) and t.assertJSXEmptyExpression(node, opts).

Aliases: JSX


jsxExpressionContainer#

t.jsxExpressionContainer(expression);
JSXExpressionContainer

<MyComponent foo={1 + 2 + 3 + 4} />

See also t.isJSXExpressionContainer(node, opts) and t.assertJSXExpressionContainer(node, opts).

AST Node JSXExpressionContainer shape:

Aliases: JSX, Immutable


jsxFragment#

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

const TableData = () => {
  return (
    <>
      <td>John Doe</td>
      <td>36</td>
      <td>Developer</td>;
    </>
  );
}

See also t.isJSXFragment(node, opts) and t.assertJSXFragment(node, opts).

AST Node JSXFragment shape:

Aliases: JSX, Immutable, Expression


jsxIdentifier#

t.jsxIdentifier(name);
JSXIdentifier

const Button = () => {
  return <button
    size="sm"
    textColor="white"
    bgColor="blue-500">
      Enable
  </button>;
};

See also t.isJSXIdentifier(node, opts) and t.assertJSXIdentifier(node, opts).

AST Node JSXIdentifier shape:

  • name: string (required)

Aliases: JSX


jsxMemberExpression#

t.jsxMemberExpression(object, property);
JSXMemberExpression

const TableData = () => {
  return (
    <Style.Table>
      <td>John Doe</td>
      <td>36</td>
      <td>Developer</td>;
    </Style.Table>
  );
}

const Spread = () => <React.Fragment>
	...
</React.Fragment>;

See also t.isJSXMemberExpression(node, opts) and t.assertJSXMemberExpression(node, opts).

AST Node JSXMemberExpression shape:

Aliases: JSX


jsxNamespacedName#

t.jsxNamespacedName(namespace, name);
JSXNamespacedName

declare namespace JSX {
  interface IntrinsicElements {
    'a:b': any;
  }
}

<a:b>
    Text
</a:b>;

//...

<div foo:bar="1">
  Element
</div>

//...

const x = <Foo x:y="hello" />;
const y = <Foo x : y="hello" />;

See also t.isJSXNamespacedName(node, opts) and t.assertJSXNamespacedName(node, opts).

AST Node JSXNamespacedName shape:

Aliases: JSX


jsxOpeningElement#

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

const Button = () => {
  return <button size="sm" textColor="white" bgColor="blue-500">
    Enable
  </button>;
};

See also t.isJSXOpeningElement(node, opts) and t.assertJSXOpeningElement(node, opts).

AST Node JSXOpeningElement shape:

Aliases: JSX, Immutable


jsxOpeningFragment#

t.jsxOpeningFragment();
JSXOpeningFragment

const TableData = () => {
  return (
    <>
      <td>John Doe</td>
      <td>36</td>
      <td>Developer</td>;
    </>
  );
}

See also t.isJSXOpeningFragment(node, opts) and t.assertJSXOpeningFragment(node, opts).

Aliases: JSX, Immutable


jsxSpreadAttribute#

t.jsxSpreadAttribute(argument);
JSXSpreadAttribute

const Button = ({...params}) => {
  return <button {...params}>
    Enable
  </button>;
};

See also t.isJSXSpreadAttribute(node, opts) and t.assertJSXSpreadAttribute(node, opts).

AST Node JSXSpreadAttribute shape:

Aliases: JSX


jsxSpreadChild#

t.jsxSpreadChild(expression);
JSXSpreadChild

const Button = ({elements, ...params}) => {
  return <button >
    {...elements}
  </button>;
};

See also t.isJSXSpreadChild(node, opts) and t.assertJSXSpreadChild(node, opts).

AST Node JSXSpreadChild shape:

Aliases: JSX, Immutable


jsxText#

t.jsxText(value);
JSXText

const Button = () => {
  return <button size="sm" textColor="white" bgColor="blue-500">
    Enable
  </button>;
};

See also t.isJSXText(node, opts) and t.assertJSXText(node, opts).

AST Node JSXText shape:

  • value: string (required)

Aliases: JSX, Immutable


labeledStatement#

t.labeledStatement(label, body);
LabeledStatement

let i = 0;

myLoop: while(true){
  i++;
  if (i>5) {
	break myLoop;
  }
}

See also t.isLabeledStatement(node, opts) and t.assertLabeledStatement(node, opts).

AST Node LabeledStatement shape:

Aliases: Standardized, Statement


logicalExpression#

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

See also t.isLogicalExpression(node, opts) and t.assertLogicalExpression(node, opts).

AST Node LogicalExpression shape:

Aliases: Standardized, Binary, Expression


memberExpression#

t.memberExpression(object, property, computed, optional);
MemberExpression

See also t.isMemberExpression(node, opts) and t.assertMemberExpression(node, opts).

AST Node MemberExpression shape:

  • object: Expression | Super (required)
  • property: if computed then Expression else Identifier (required)
  • computed: boolean (default: false)
  • optional: true | false (default: null)

Aliases: Standardized, Expression, LVal


metaProperty#

t.metaProperty(meta, property);
MetaProperty

const info = new URL(import.meta.url).searchParams.get("someURLInfo");

//

function Foo() {
  if (!new.target) {
    throw new TypeError('calling Foo constructor without new is invalid');
  }
}

See also t.isMetaProperty(node, opts) and t.assertMetaProperty(node, opts).

AST Node MetaProperty shape:

Aliases: Standardized, Expression


mixedTypeAnnotation#

t.mixedTypeAnnotation();
MixedTypeAnnotation

See also t.isMixedTypeAnnotation(node, opts) and t.assertMixedTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


moduleExpression#

t.moduleExpression(body);
ModuleExpression

module {
  export const a = 'A';
}

See also t.isModuleExpression(node, opts) and t.assertModuleExpression(node, opts).

AST Node ModuleExpression shape:

Aliases: Expression


newExpression#

t.newExpression(callee, arguments);
NewExpression

function Car() {}

const car1 = new Car();
const car2 = new Car();

//

class Person {
  constructor(name) {
    this.name = name;
  }
  greet() {
    console.log(`Hello, my name is ${this.name}`);
  }
}

const p = new Person("Caroline");

//

function Foo() {
  // not NewExpression but MetaProperty
  if (!new.target) {
    throw new TypeError('calling Foo constructor without new is invalid');
  }
}

See also t.isNewExpression(node, opts) and t.assertNewExpression(node, opts).

AST Node NewExpression shape:

Aliases: Standardized, Expression


noop#

t.noop();
Noop

See also t.isNoop(node, opts) and t.assertNoop(node, opts).

Aliases: Miscellaneous


nullLiteral#

t.nullLiteral();
NullLiteral

See also t.isNullLiteral(node, opts) and t.assertNullLiteral(node, opts).

Aliases: Standardized, Expression, Pureish, Literal, Immutable


nullLiteralTypeAnnotation#

t.nullLiteralTypeAnnotation();
NullLiteralTypeAnnotation

See also t.isNullLiteralTypeAnnotation(node, opts) and t.assertNullLiteralTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


nullableTypeAnnotation#

t.nullableTypeAnnotation(typeAnnotation);
NullableTypeAnnotation

See also t.isNullableTypeAnnotation(node, opts) and t.assertNullableTypeAnnotation(node, opts).

AST Node NullableTypeAnnotation shape:

Aliases: Flow, FlowType


numberLiteralTypeAnnotation#

t.numberLiteralTypeAnnotation(value);
NumberLiteralTypeAnnotation

See also t.isNumberLiteralTypeAnnotation(node, opts) and t.assertNumberLiteralTypeAnnotation(node, opts).

AST Node NumberLiteralTypeAnnotation shape:

  • value: number (required)

Aliases: Flow, FlowType


numberTypeAnnotation#

t.numberTypeAnnotation();
NumberTypeAnnotation

See also t.isNumberTypeAnnotation(node, opts) and t.assertNumberTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


numericLiteral#

t.numericLiteral(value);
NumericLiteral

See also t.isNumericLiteral(node, opts) and t.assertNumericLiteral(node, opts).

AST Node NumericLiteral shape:

  • value: a non-negative finite number (required)

Aliases: Standardized, Expression, Pureish, Literal, Immutable


objectExpression#

t.objectExpression(properties);
ObjectExpression

const obj = {
  name: "foo",
  
  foo() {
    //..
  }
};

See also t.isObjectExpression(node, opts) and t.assertObjectExpression(node, opts).

AST Node ObjectExpression shape:

Aliases: Standardized, Expression


objectMethod#

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

const obj = {
  foo() {
    //..
  }
};

See also t.isObjectMethod(node, opts) and t.assertObjectMethod(node, opts).

AST Node ObjectMethod shape:

Aliases: Standardized, UserWhitespacable, Function, Scopable, BlockParent, FunctionParent, Method, ObjectMember


objectPattern#

t.objectPattern(properties);
ObjectPattern

function foo({ name, address }) {
  
  const { street } = address;

  //..
}

See also t.isObjectPattern(node, opts) and t.assertObjectPattern(node, opts).

AST Node ObjectPattern shape:

Aliases: Standardized, Pattern, PatternLike, LVal


objectProperty#

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

const obj = {
  name: "foo",
  
  foo() {
    //..
  }
}

See also t.isObjectProperty(node, opts) and t.assertObjectProperty(node, opts).

AST Node ObjectProperty shape:

  • key: if computed then Expression else Identifier | Literal (required)
  • value: Expression | PatternLike (required)
  • computed: boolean (default: false)
  • shorthand: boolean (default: false)
  • decorators: Array<Decorator> (default: null)

Aliases: Standardized, UserWhitespacable, Property, ObjectMember


objectTypeAnnotation#

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

See also t.isObjectTypeAnnotation(node, opts) and t.assertObjectTypeAnnotation(node, opts).

AST Node ObjectTypeAnnotation shape:

Aliases: Flow, FlowType


objectTypeCallProperty#

t.objectTypeCallProperty(value);
ObjectTypeCallProperty

See also t.isObjectTypeCallProperty(node, opts) and t.assertObjectTypeCallProperty(node, opts).

AST Node ObjectTypeCallProperty shape:

  • value: FlowType (required)
  • static: boolean (required)

Aliases: Flow, UserWhitespacable


objectTypeIndexer#

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

See also t.isObjectTypeIndexer(node, opts) and t.assertObjectTypeIndexer(node, opts).

AST Node ObjectTypeIndexer shape:

Aliases: Flow, UserWhitespacable


objectTypeInternalSlot#

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

See also t.isObjectTypeInternalSlot(node, opts) and t.assertObjectTypeInternalSlot(node, opts).

AST Node ObjectTypeInternalSlot shape:

  • id: Identifier (required)
  • value: FlowType (required)
  • optional: boolean (required)
  • static: boolean (required)
  • method: boolean (required)

Aliases: Flow, UserWhitespacable


objectTypeProperty#

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

See also t.isObjectTypeProperty(node, opts) and t.assertObjectTypeProperty(node, opts).

AST Node ObjectTypeProperty shape:

  • key: Identifier | StringLiteral (required)
  • value: FlowType (required)
  • variance: Variance (default: null)
  • kind: "init" | "get" | "set" (required)
  • method: boolean (required)
  • optional: boolean (required)
  • proto: boolean (required)
  • static: boolean (required)

Aliases: Flow, UserWhitespacable


objectTypeSpreadProperty#

t.objectTypeSpreadProperty(argument);
ObjectTypeSpreadProperty

See also t.isObjectTypeSpreadProperty(node, opts) and t.assertObjectTypeSpreadProperty(node, opts).

AST Node ObjectTypeSpreadProperty shape:

Aliases: Flow, UserWhitespacable


opaqueType#

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

opaque type ID = string;

function identity(x: ID): ID {
  return x;
}
export type {ID};

opaque type ObjectAlias = {
  property: string,
  method(): number,
};

See also t.isOpaqueType(node, opts) and t.assertOpaqueType(node, opts).

AST Node OpaqueType shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


optionalCallExpression#

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

See also t.isOptionalCallExpression(node, opts) and t.assertOptionalCallExpression(node, opts).

AST Node OptionalCallExpression shape:

Aliases: Standardized, Expression


optionalIndexedAccessType#

t.optionalIndexedAccessType(objectType, indexType);
OptionalIndexedAccessType

type T = Obj?.['prop'];

type TasksContent = ?{
  tasks?: Array<{
    items?: {
      metadata?: {
        title: string,
        completed: boolean,
      },
    },
  }>,
};

type TaskData = TasksContent?.['tasks']?.[number]?.['items']?.['metadata'];

See also t.isOptionalIndexedAccessType(node, opts) and t.assertOptionalIndexedAccessType(node, opts).

AST Node OptionalIndexedAccessType shape:

  • objectType: FlowType (required)
  • indexType: FlowType (required)
  • optional: boolean (required)

Aliases: Flow, FlowType


optionalMemberExpression#

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

See also t.isOptionalMemberExpression(node, opts) and t.assertOptionalMemberExpression(node, opts).

AST Node OptionalMemberExpression shape:

Aliases: Standardized, Expression


parenthesizedExpression#

t.parenthesizedExpression(expression);
ParenthesizedExpression

See also t.isParenthesizedExpression(node, opts) and t.assertParenthesizedExpression(node, opts).

AST Node ParenthesizedExpression shape:

Aliases: Standardized, Expression, ExpressionWrapper


pipelineBareFunction#

t.pipelineBareFunction(callee);
PipelineBareFunction

See also t.isPipelineBareFunction(node, opts) and t.assertPipelineBareFunction(node, opts).

AST Node PipelineBareFunction shape:

Aliases: Expression


pipelinePrimaryTopicReference#

t.pipelinePrimaryTopicReference();
PipelinePrimaryTopicReference

See also t.isPipelinePrimaryTopicReference(node, opts) and t.assertPipelinePrimaryTopicReference(node, opts).

Aliases: Expression


pipelineTopicExpression#

t.pipelineTopicExpression(expression);
PipelineTopicExpression

See also t.isPipelineTopicExpression(node, opts) and t.assertPipelineTopicExpression(node, opts).

AST Node PipelineTopicExpression shape:

Aliases: Expression


placeholder#

t.placeholder(expectedNode, name);
Placeholder

See also t.isPlaceholder(node, opts) and t.assertPlaceholder(node, opts).

AST Node Placeholder shape:

  • expectedNode: "Identifier" | "StringLiteral" | "Expression" | "Statement" | "Declaration" | "BlockStatement" | "ClassBody" | "Pattern" (required)
  • name: Identifier (required)

Aliases: Miscellaneous


privateName#

t.privateName(id);
PrivateName

class Klass {
  
  #a=3
  
  #foo() {
    //..
  }
  
  b=4
  
  bar() {
    //...
  }
}

See also t.isPrivateName(node, opts) and t.assertPrivateName(node, opts).

AST Node PrivateName shape:

Aliases: Standardized, Private


program#

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

// Program is a top level node contained only by File,
// its "sourceType" field values can be `module` or `script`
// and "body" field contains all the expressions and declarations in global scope.

// Program is also the body content of a module declaration
module {
  const a="A";
  let b=0;
  
  export default {a, b};
}

See also t.isProgram(node, opts) and t.assertProgram(node, opts).

AST Node Program shape:

  • body: Array<Statement> (required)
  • directives: Array<Directive> (default: [])
  • sourceType: "script" | "module" (default: 'script')
  • interpreter: InterpreterDirective (default: null)
  • sourceFile: string (required)

Aliases: Standardized, Scopable, BlockParent, Block


qualifiedTypeIdentifier#

t.qualifiedTypeIdentifier(id, qualification);
QualifiedTypeIdentifier

See also t.isQualifiedTypeIdentifier(node, opts) and t.assertQualifiedTypeIdentifier(node, opts).

AST Node QualifiedTypeIdentifier shape:

Aliases: Flow


recordExpression#

t.recordExpression(properties);
RecordExpression

const drivingLicence = #{
    country: "UK",
    number: 123456789870,
};
const milesCard = {
    rank: "gold",
    numero: 123456,
};

console.log(drivingLicence === #{
    country: "UK",
    number: 123456789870,
}); // => true

console.log(milesCard === {
    rank: "gold",
    numero: 123456,
}); // => false

See also t.isRecordExpression(node, opts) and t.assertRecordExpression(node, opts).

AST Node RecordExpression shape:

Aliases: Expression


regExpLiteral#

t.regExpLiteral(pattern, flags);
RegExpLiteral

const re1 = /^ab+c$/gi; // literal notation

const re2 = new RegExp("ab+c", "i"); // constructor with string pattern as first argument

const re3 = new RegExp(/ab+c/, "i"); // constructor with regular expression literal as first argument

See also t.isRegExpLiteral(node, opts) and t.assertRegExpLiteral(node, opts).

AST Node RegExpLiteral shape:

  • pattern: string (required)
  • flags: string (default: '')

Aliases: Standardized, Expression, Pureish, Literal


restElement#

t.restElement(argument);
RestElement

function sum(...theArgs) {
  let total = 0;
  for (const arg of theArgs) {
    total += arg;
  }
  return total;
}

sum(1, 2, 3);
// Output: 6

See also t.isRestElement(node, opts) and t.assertRestElement(node, opts).

AST Node RestElement shape:

  • argument: LVal (required)
  • decorators: Array<Decorator> (default: null, excluded from builder function)
  • optional: boolean (default: null, excluded from builder function)
  • typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop (default: null, excluded from builder function)

Aliases: Standardized, LVal, PatternLike


returnStatement#

t.returnStatement(argument);
ReturnStatement

function getRectArea(width, height) {
  if (width > 0 && height > 0) {
    return width * height;
  }
  return 0;
}

console.log(getRectArea(3, 4)); // 12

See also t.isReturnStatement(node, opts) and t.assertReturnStatement(node, opts).

AST Node ReturnStatement shape:

Aliases: Standardized, Statement, Terminatorless, CompletionStatement


sequenceExpression#

t.sequenceExpression(expressions);
SequenceExpression

1,2,3;

(true, false);

See also t.isSequenceExpression(node, opts) and t.assertSequenceExpression(node, opts).

AST Node SequenceExpression shape:

Aliases: Standardized, Expression


spreadElement#

t.spreadElement(argument);
SpreadElement

See also t.isSpreadElement(node, opts) and t.assertSpreadElement(node, opts).

AST Node SpreadElement shape:

Aliases: Standardized, UnaryLike


staticBlock#

t.staticBlock(body);
StaticBlock

See also t.isStaticBlock(node, opts) and t.assertStaticBlock(node, opts).

AST Node StaticBlock shape:

Aliases: Standardized, Scopable, BlockParent, FunctionParent


stringLiteral#

t.stringLiteral(value);
StringLiteral

See also t.isStringLiteral(node, opts) and t.assertStringLiteral(node, opts).

AST Node StringLiteral shape:

  • value: string (required)

Aliases: Standardized, Expression, Pureish, Literal, Immutable


stringLiteralTypeAnnotation#

t.stringLiteralTypeAnnotation(value);
StringLiteralTypeAnnotation

// Flow

let str: 'abc' = 'abc';

See also t.isStringLiteralTypeAnnotation(node, opts) and t.assertStringLiteralTypeAnnotation(node, opts).

AST Node StringLiteralTypeAnnotation shape:

  • value: string (required)

Aliases: Flow, FlowType


stringTypeAnnotation#

t.stringTypeAnnotation();
StringTypeAnnotation

let name:string;

function calc(str:string):string {
	//...
}

See also t.isStringTypeAnnotation(node, opts) and t.assertStringTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


super#

t.super();
Super

class Rectangle {
  static logNbSides() {
    return "I have 4 sides";
  }
}

class Square extends Rectangle {
  static logDescription() {
    return `${super.logNbSides()} which are all equal`;
  }

    
  constructor() {
    super();
  }
}
Square.logDescription(); // 'I have 4 sides which are all equal'

See also t.isSuper(node, opts) and t.assertSuper(node, opts).

Aliases: Standardized, Expression


switchCase#

t.switchCase(test, consequent);
SwitchCase

const expr = 'Papayas';
switch (expr) {
  case 'Oranges':
    console.log('Oranges are $0.59 a pound.');
    break;
  case 'Mangoes':
  case 'Papayas':
    console.log('Mangoes and papayas are $2.79 a pound.');
    // Expected output: "Mangoes and papayas are $2.79 a pound."
    break;
  default:
    console.log(`Sorry, we are out of ${expr}.`);
}

See also t.isSwitchCase(node, opts) and t.assertSwitchCase(node, opts).

AST Node SwitchCase shape:

Aliases: Standardized


switchStatement#

t.switchStatement(discriminant, cases);
SwitchStatement

const expr = 'Papayas';
switch (expr) {
  case 'Oranges':
    console.log('Oranges are $0.59 a pound.');
    break;
  case 'Mangoes':
  case 'Papayas':
    console.log('Mangoes and papayas are $2.79 a pound.');
    // Expected output: "Mangoes and papayas are $2.79 a pound."
    break;
  default:
    console.log(`Sorry, we are out of ${expr}.`);
}

See also t.isSwitchStatement(node, opts) and t.assertSwitchStatement(node, opts).

AST Node SwitchStatement shape:

Aliases: Standardized, Statement, BlockParent, Scopable


symbolTypeAnnotation#

t.symbolTypeAnnotation();
SymbolTypeAnnotation

See also t.isSymbolTypeAnnotation(node, opts) and t.assertSymbolTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


tsAnyKeyword#

t.tsAnyKeyword();
TSAnyKeyword

See also t.isTSAnyKeyword(node, opts) and t.assertTSAnyKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsArrayType#

t.tsArrayType(elementType);
TSArrayType

See also t.isTSArrayType(node, opts) and t.assertTSArrayType(node, opts).

AST Node TSArrayType shape:

  • elementType: TSType (required)

Aliases: TypeScript, TSType


tsAsExpression#

t.tsAsExpression(expression, typeAnnotation);
TSAsExpression

See also t.isTSAsExpression(node, opts) and t.assertTSAsExpression(node, opts).

AST Node TSAsExpression shape:

Aliases: TypeScript, Expression, LVal, PatternLike


tsBigIntKeyword#

t.tsBigIntKeyword();
TSBigIntKeyword

let decimal: number = 6;
let hex: number = 0xf00d;
let binary: number = 0b1010;
let octal: number = 0o744;
let big: bigint = 100n;

See also t.isTSBigIntKeyword(node, opts) and t.assertTSBigIntKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsBooleanKeyword#

t.tsBooleanKeyword();
TSBooleanKeyword

See also t.isTSBooleanKeyword(node, opts) and t.assertTSBooleanKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsCallSignatureDeclaration#

t.tsCallSignatureDeclaration(typeParameters, parameters, typeAnnotation);
TSCallSignatureDeclaration

See also t.isTSCallSignatureDeclaration(node, opts) and t.assertTSCallSignatureDeclaration(node, opts).

AST Node TSCallSignatureDeclaration shape:

Aliases: TypeScript, TSTypeElement


tsConditionalType#

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

See also t.isTSConditionalType(node, opts) and t.assertTSConditionalType(node, opts).

AST Node TSConditionalType shape:

Aliases: TypeScript, TSType


tsConstructSignatureDeclaration#

t.tsConstructSignatureDeclaration(typeParameters, parameters, typeAnnotation);
TSConstructSignatureDeclaration

See also t.isTSConstructSignatureDeclaration(node, opts) and t.assertTSConstructSignatureDeclaration(node, opts).

AST Node TSConstructSignatureDeclaration shape:

Aliases: TypeScript, TSTypeElement


tsConstructorType#

t.tsConstructorType(typeParameters, parameters, typeAnnotation);
TSConstructorType

See also t.isTSConstructorType(node, opts) and t.assertTSConstructorType(node, opts).

AST Node TSConstructorType shape:

Aliases: TypeScript, TSType


tsDeclareFunction#

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

See also t.isTSDeclareFunction(node, opts) and t.assertTSDeclareFunction(node, opts).

AST Node TSDeclareFunction shape:

Aliases: TypeScript, Statement, Declaration


tsDeclareMethod#

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

See also t.isTSDeclareMethod(node, opts) and t.assertTSDeclareMethod(node, opts).

AST Node TSDeclareMethod shape:

  • decorators: Array<Decorator> (default: null)
  • key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression (required)
  • typeParameters: TSTypeParameterDeclaration | Noop (default: null)
  • params: Array<Identifier | Pattern | RestElement | TSParameterProperty> (required)
  • returnType: TSTypeAnnotation | Noop (default: null)
  • abstract: boolean (default: null, excluded from builder function)
  • access: "public" | "private" | "protected" (default: null, excluded from builder function)
  • accessibility: "public" | "private" | "protected" (default: null, excluded from builder function)
  • async: boolean (default: false, excluded from builder function)
  • computed: boolean (default: false, excluded from builder function)
  • generator: boolean (default: false, excluded from builder function)
  • kind: "get" | "set" | "method" | "constructor" (default: 'method', excluded from builder function)
  • optional: boolean (default: null, excluded from builder function)
  • override: boolean (default: false, excluded from builder function)
  • static: boolean (default: false, excluded from builder function)

Aliases: TypeScript


tsEnumDeclaration#

t.tsEnumDeclaration(id, members);
TSEnumDeclaration

See also t.isTSEnumDeclaration(node, opts) and t.assertTSEnumDeclaration(node, opts).

AST Node TSEnumDeclaration shape:

  • id: Identifier (required)
  • members: Array<TSEnumMember> (required)
  • const: boolean (default: null, excluded from builder function)
  • declare: boolean (default: null, excluded from builder function)
  • initializer: Expression (default: null, excluded from builder function)

Aliases: TypeScript, Statement, Declaration


tsEnumMember#

t.tsEnumMember(id, initializer);
TSEnumMember

See also t.isTSEnumMember(node, opts) and t.assertTSEnumMember(node, opts).

AST Node TSEnumMember shape:

Aliases: TypeScript


tsExportAssignment#

t.tsExportAssignment(expression);
TSExportAssignment

See also t.isTSExportAssignment(node, opts) and t.assertTSExportAssignment(node, opts).

AST Node TSExportAssignment shape:

Aliases: TypeScript, Statement


tsExpressionWithTypeArguments#

t.tsExpressionWithTypeArguments(expression, typeParameters);
TSExpressionWithTypeArguments

See also t.isTSExpressionWithTypeArguments(node, opts) and t.assertTSExpressionWithTypeArguments(node, opts).

AST Node TSExpressionWithTypeArguments shape:

Aliases: TypeScript, TSType


tsExternalModuleReference#

t.tsExternalModuleReference(expression);
TSExternalModuleReference

See also t.isTSExternalModuleReference(node, opts) and t.assertTSExternalModuleReference(node, opts).

AST Node TSExternalModuleReference shape:

Aliases: TypeScript


tsFunctionType#

t.tsFunctionType(typeParameters, parameters, typeAnnotation);
TSFunctionType

See also t.isTSFunctionType(node, opts) and t.assertTSFunctionType(node, opts).

AST Node TSFunctionType shape:

Aliases: TypeScript, TSType


tsImportEqualsDeclaration#

t.tsImportEqualsDeclaration(id, moduleReference);
TSImportEqualsDeclaration

See also t.isTSImportEqualsDeclaration(node, opts) and t.assertTSImportEqualsDeclaration(node, opts).

AST Node TSImportEqualsDeclaration shape:

Aliases: TypeScript, Statement


tsImportType#

t.tsImportType(argument, qualifier, typeParameters);
TSImportType

See also t.isTSImportType(node, opts) and t.assertTSImportType(node, opts).

AST Node TSImportType shape:

Aliases: TypeScript, TSType


tsIndexSignature#

t.tsIndexSignature(parameters, typeAnnotation);
TSIndexSignature

See also t.isTSIndexSignature(node, opts) and t.assertTSIndexSignature(node, opts).

AST Node TSIndexSignature shape:

  • parameters: Array<Identifier> (required)
  • typeAnnotation: TSTypeAnnotation (default: null)
  • readonly: boolean (default: null, excluded from builder function)
  • static: boolean (default: null, excluded from builder function)

Aliases: TypeScript, TSTypeElement


tsIndexedAccessType#

t.tsIndexedAccessType(objectType, indexType);
TSIndexedAccessType

See also t.isTSIndexedAccessType(node, opts) and t.assertTSIndexedAccessType(node, opts).

AST Node TSIndexedAccessType shape:

  • objectType: TSType (required)
  • indexType: TSType (required)

Aliases: TypeScript, TSType


tsInferType#

t.tsInferType(typeParameter);
TSInferType

See also t.isTSInferType(node, opts) and t.assertTSInferType(node, opts).

AST Node TSInferType shape:

Aliases: TypeScript, TSType


tsInstantiationExpression#

t.tsInstantiationExpression(expression, typeParameters);
TSInstantiationExpression

See also t.isTSInstantiationExpression(node, opts) and t.assertTSInstantiationExpression(node, opts).

AST Node TSInstantiationExpression shape:

Aliases: TypeScript, Expression


tsInterfaceBody#

t.tsInterfaceBody(body);
TSInterfaceBody

See also t.isTSInterfaceBody(node, opts) and t.assertTSInterfaceBody(node, opts).

AST Node TSInterfaceBody shape:

Aliases: TypeScript


tsInterfaceDeclaration#

t.tsInterfaceDeclaration(id, typeParameters, extends, body);
TSInterfaceDeclaration

See also t.isTSInterfaceDeclaration(node, opts) and t.assertTSInterfaceDeclaration(node, opts).

AST Node TSInterfaceDeclaration shape:

Aliases: TypeScript, Statement, Declaration


tsIntersectionType#

t.tsIntersectionType(types);
TSIntersectionType

See also t.isTSIntersectionType(node, opts) and t.assertTSIntersectionType(node, opts).

AST Node TSIntersectionType shape:

  • types: Array<TSType> (required)

Aliases: TypeScript, TSType


tsIntrinsicKeyword#

t.tsIntrinsicKeyword();
TSIntrinsicKeyword

See also t.isTSIntrinsicKeyword(node, opts) and t.assertTSIntrinsicKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsLiteralType#

t.tsLiteralType(literal);
TSLiteralType

See also t.isTSLiteralType(node, opts) and t.assertTSLiteralType(node, opts).

AST Node TSLiteralType shape:

Aliases: TypeScript, TSType, TSBaseType


tsMappedType#

t.tsMappedType(typeParameter, typeAnnotation, nameType);
TSMappedType

See also t.isTSMappedType(node, opts) and t.assertTSMappedType(node, opts).

AST Node TSMappedType shape:

  • typeParameter: TSTypeParameter (required)
  • typeAnnotation: TSType (default: null)
  • nameType: TSType (default: null)
  • optional: true | false | "+" | "-" (default: null, excluded from builder function)
  • readonly: true | false | "+" | "-" (default: null, excluded from builder function)

Aliases: TypeScript, TSType


tsMethodSignature#

t.tsMethodSignature(key, typeParameters, parameters, typeAnnotation);
TSMethodSignature

See also t.isTSMethodSignature(node, opts) and t.assertTSMethodSignature(node, opts).

AST Node TSMethodSignature shape:

Aliases: TypeScript, TSTypeElement


tsModuleBlock#

t.tsModuleBlock(body);
TSModuleBlock

See also t.isTSModuleBlock(node, opts) and t.assertTSModuleBlock(node, opts).

AST Node TSModuleBlock shape:

Aliases: TypeScript, Scopable, Block, BlockParent, FunctionParent


tsModuleDeclaration#

t.tsModuleDeclaration(id, body);
TSModuleDeclaration

See also t.isTSModuleDeclaration(node, opts) and t.assertTSModuleDeclaration(node, opts).

AST Node TSModuleDeclaration shape:

Aliases: TypeScript, Statement, Declaration


tsNamedTupleMember#

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

See also t.isTSNamedTupleMember(node, opts) and t.assertTSNamedTupleMember(node, opts).

AST Node TSNamedTupleMember shape:

  • label: Identifier (required)
  • elementType: TSType (required)
  • optional: boolean (default: false)

Aliases: TypeScript


tsNamespaceExportDeclaration#

t.tsNamespaceExportDeclaration(id);
TSNamespaceExportDeclaration

See also t.isTSNamespaceExportDeclaration(node, opts) and t.assertTSNamespaceExportDeclaration(node, opts).

AST Node TSNamespaceExportDeclaration shape:

Aliases: TypeScript, Statement


tsNeverKeyword#

t.tsNeverKeyword();
TSNeverKeyword

See also t.isTSNeverKeyword(node, opts) and t.assertTSNeverKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsNonNullExpression#

t.tsNonNullExpression(expression);
TSNonNullExpression

See also t.isTSNonNullExpression(node, opts) and t.assertTSNonNullExpression(node, opts).

AST Node TSNonNullExpression shape:

Aliases: TypeScript, Expression, LVal, PatternLike


tsNullKeyword#

t.tsNullKeyword();
TSNullKeyword

See also t.isTSNullKeyword(node, opts) and t.assertTSNullKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsNumberKeyword#

t.tsNumberKeyword();
TSNumberKeyword

let decimal: number = 6;
let hex: number = 0xf00d;
let binary: number = 0b1010;
let octal: number = 0o744;
let big: bigint = 100n;

See also t.isTSNumberKeyword(node, opts) and t.assertTSNumberKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsObjectKeyword#

t.tsObjectKeyword();
TSObjectKeyword

See also t.isTSObjectKeyword(node, opts) and t.assertTSObjectKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsOptionalType#

t.tsOptionalType(typeAnnotation);
TSOptionalType

See also t.isTSOptionalType(node, opts) and t.assertTSOptionalType(node, opts).

AST Node TSOptionalType shape:

  • typeAnnotation: TSType (required)

Aliases: TypeScript, TSType


tsParameterProperty#

t.tsParameterProperty(parameter);
TSParameterProperty

See also t.isTSParameterProperty(node, opts) and t.assertTSParameterProperty(node, opts).

AST Node TSParameterProperty shape:

  • parameter: Identifier | AssignmentPattern (required)
  • accessibility: "public" | "private" | "protected" (default: null, excluded from builder function)
  • decorators: Array<Decorator> (default: null, excluded from builder function)
  • override: boolean (default: null, excluded from builder function)
  • readonly: boolean (default: null, excluded from builder function)

Aliases: TypeScript, LVal


tsParenthesizedType#

t.tsParenthesizedType(typeAnnotation);
TSParenthesizedType

See also t.isTSParenthesizedType(node, opts) and t.assertTSParenthesizedType(node, opts).

AST Node TSParenthesizedType shape:

  • typeAnnotation: TSType (required)

Aliases: TypeScript, TSType


tsPropertySignature#

t.tsPropertySignature(key, typeAnnotation, initializer);
TSPropertySignature

See also t.isTSPropertySignature(node, opts) and t.assertTSPropertySignature(node, opts).

AST Node TSPropertySignature shape:

  • key: Expression (required)
  • typeAnnotation: TSTypeAnnotation (default: null)
  • initializer: Expression (default: null)
  • computed: boolean (default: false, excluded from builder function)
  • kind: "get" | "set" (required)
  • optional: boolean (default: null, excluded from builder function)
  • readonly: boolean (default: null, excluded from builder function)

Aliases: TypeScript, TSTypeElement


tsQualifiedName#

t.tsQualifiedName(left, right);
TSQualifiedName

See also t.isTSQualifiedName(node, opts) and t.assertTSQualifiedName(node, opts).

AST Node TSQualifiedName shape:

Aliases: TypeScript, TSEntityName


tsRestType#

t.tsRestType(typeAnnotation);
TSRestType

See also t.isTSRestType(node, opts) and t.assertTSRestType(node, opts).

AST Node TSRestType shape:

  • typeAnnotation: TSType (required)

Aliases: TypeScript, TSType


tsSatisfiesExpression#

t.tsSatisfiesExpression(expression, typeAnnotation);
TSSatisfiesExpression

History

| Version | Changes | | --- | --- | | v7.20.0 | Introduced |

See also t.isTSSatisfiesExpression(node, opts) and t.assertTSSatisfiesExpression(node, opts).

AST Node TSSatisfiesExpression shape:

Aliases: TypeScript, Expression, LVal, PatternLike


tsStringKeyword#

t.tsStringKeyword();
TSStringKeyword

See also t.isTSStringKeyword(node, opts) and t.assertTSStringKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsSymbolKeyword#

t.tsSymbolKeyword();
TSSymbolKeyword

See also t.isTSSymbolKeyword(node, opts) and t.assertTSSymbolKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsThisType#

t.tsThisType();
TSThisType

See also t.isTSThisType(node, opts) and t.assertTSThisType(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsTupleType#

t.tsTupleType(elementTypes);
TSTupleType

See also t.isTSTupleType(node, opts) and t.assertTSTupleType(node, opts).

AST Node TSTupleType shape:

Aliases: TypeScript, TSType


tsTypeAliasDeclaration#

t.tsTypeAliasDeclaration(id, typeParameters, typeAnnotation);
TSTypeAliasDeclaration

See also t.isTSTypeAliasDeclaration(node, opts) and t.assertTSTypeAliasDeclaration(node, opts).

AST Node TSTypeAliasDeclaration shape:

Aliases: TypeScript, Statement, Declaration


tsTypeAnnotation#

t.tsTypeAnnotation(typeAnnotation);
TSTypeAnnotation

See also t.isTSTypeAnnotation(node, opts) and t.assertTSTypeAnnotation(node, opts).

AST Node TSTypeAnnotation shape:

  • typeAnnotation: TSType (required)

Aliases: TypeScript


tsTypeAssertion#

t.tsTypeAssertion(typeAnnotation, expression);
TSTypeAssertion

See also t.isTSTypeAssertion(node, opts) and t.assertTSTypeAssertion(node, opts).

AST Node TSTypeAssertion shape:

Aliases: TypeScript, Expression, LVal, PatternLike


tsTypeLiteral#

t.tsTypeLiteral(members);
TSTypeLiteral

See also t.isTSTypeLiteral(node, opts) and t.assertTSTypeLiteral(node, opts).

AST Node TSTypeLiteral shape:

Aliases: TypeScript, TSType


tsTypeOperator#

t.tsTypeOperator(typeAnnotation);
TSTypeOperator

See also t.isTSTypeOperator(node, opts) and t.assertTSTypeOperator(node, opts).

AST Node TSTypeOperator shape:

  • typeAnnotation: TSType (required)
  • operator: string (required)

Aliases: TypeScript, TSType


tsTypeParameter#

t.tsTypeParameter(constraint, default, name);
TSTypeParameter

History

| Version | Changes | | --- | --- | | v7.21.0 | Supports const |

See also t.isTSTypeParameter(node, opts) and t.assertTSTypeParameter(node, opts).

AST Node TSTypeParameter shape:

  • constraint: TSType (default: null)
  • default: TSType (default: null)
  • name: string (required)
  • const: boolean (default: null, excluded from builder function)
  • in: boolean (default: null, excluded from builder function)
  • out: boolean (default: null, excluded from builder function)

Aliases: TypeScript


tsTypeParameterDeclaration#

t.tsTypeParameterDeclaration(params);
TSTypeParameterDeclaration

See also t.isTSTypeParameterDeclaration(node, opts) and t.assertTSTypeParameterDeclaration(node, opts).

AST Node TSTypeParameterDeclaration shape:

Aliases: TypeScript


tsTypeParameterInstantiation#

t.tsTypeParameterInstantiation(params);
TSTypeParameterInstantiation

See also t.isTSTypeParameterInstantiation(node, opts) and t.assertTSTypeParameterInstantiation(node, opts).

AST Node TSTypeParameterInstantiation shape:

  • params: Array<TSType> (required)

Aliases: TypeScript


tsTypePredicate#

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

See also t.isTSTypePredicate(node, opts) and t.assertTSTypePredicate(node, opts).

AST Node TSTypePredicate shape:

Aliases: TypeScript, TSType


tsTypeQuery#

t.tsTypeQuery(exprName, typeParameters);
TSTypeQuery

See also t.isTSTypeQuery(node, opts) and t.assertTSTypeQuery(node, opts).

AST Node TSTypeQuery shape:

Aliases: TypeScript, TSType


tsTypeReference#

t.tsTypeReference(typeName, typeParameters);
TSTypeReference

See also t.isTSTypeReference(node, opts) and t.assertTSTypeReference(node, opts).

AST Node TSTypeReference shape:

Aliases: TypeScript, TSType


tsUndefinedKeyword#

t.tsUndefinedKeyword();
TSUndefinedKeyword

See also t.isTSUndefinedKeyword(node, opts) and t.assertTSUndefinedKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsUnionType#

t.tsUnionType(types);
TSUnionType

// Typescript

function eatSomething(food: 'sushi' | 'ramen') {
	// ...
}

See also t.isTSUnionType(node, opts) and t.assertTSUnionType(node, opts).

AST Node TSUnionType shape:

  • types: Array<TSType> (required)

Aliases: TypeScript, TSType


tsUnknownKeyword#

t.tsUnknownKeyword();
TSUnknownKeyword

See also t.isTSUnknownKeyword(node, opts) and t.assertTSUnknownKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


tsVoidKeyword#

t.tsVoidKeyword();
TSVoidKeyword

See also t.isTSVoidKeyword(node, opts) and t.assertTSVoidKeyword(node, opts).

Aliases: TypeScript, TSType, TSBaseType


taggedTemplateExpression#

t.taggedTemplateExpression(tag, quasi);
TaggedTemplateExpression

const doc = html`<canvas>\n</canvas>`;

See also t.isTaggedTemplateExpression(node, opts) and t.assertTaggedTemplateExpression(node, opts).

AST Node TaggedTemplateExpression shape:

Aliases: Standardized, Expression


templateElement#

t.templateElement(value, tail);
TemplateElement

`a ${b} c`

See also t.isTemplateElement(node, opts) and t.assertTemplateElement(node, opts).

AST Node TemplateElement shape:

  • value: { raw: string, cooked?: string } (required)
  • tail: boolean (default: false)

Aliases: Standardized


templateLiteral#

t.templateLiteral(quasis, expressions);
TemplateLiteral

`a ${b} c`

const doc = html`<canvas>\n</canvas>`;

See also t.isTemplateLiteral(node, opts) and t.assertTemplateLiteral(node, opts).

AST Node TemplateLiteral shape:

Aliases: Standardized, Expression, Literal


thisExpression#

t.thisExpression();
ThisExpression

const test = {
  prop: 42,
  func: function () {
    return this.prop;
  },
};

console.log(test.func()); // 42

//

function C() {
  this.a = 37;
}

let o = new C();
console.log(o.a); // 37

//

class X {
  instanceField = this;
  static staticField = this;
}

const x = new X();

//

const obj = {
  a: this,
};

console.log(obj.a === window); // true

See also t.isThisExpression(node, opts) and t.assertThisExpression(node, opts).

Aliases: Standardized, Expression


thisTypeAnnotation#

t.thisTypeAnnotation();
ThisTypeAnnotation

See also t.isThisTypeAnnotation(node, opts) and t.assertThisTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


throwStatement#

t.throwStatement(argument);
ThrowStatement

throw error;

throw new Error();

throw (
  new Error()
);

See also t.isThrowStatement(node, opts) and t.assertThrowStatement(node, opts).

AST Node ThrowStatement shape:

Aliases: Standardized, Statement, Terminatorless, CompletionStatement


topicReference#

t.topicReference();
TopicReference

See also t.isTopicReference(node, opts) and t.assertTopicReference(node, opts).

Aliases: Expression


tryStatement#

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

try {
	const foo = bar();
} catch (err) {
	console.err('Oops');
} finally{
    console.log('end');
}

See also t.isTryStatement(node, opts) and t.assertTryStatement(node, opts).

AST Node TryStatement shape:

Aliases: Standardized, Statement


tupleExpression#

t.tupleExpression(elements);
TupleExpression

const drivingLicence = #{
    country: "UK",
    number: 123456789870,
};

const creditCard = #{
    type: "Amex",
    number: 378282246310005,
};

const debitCard = #{
    type: "Visa",
    number: 4242424242424242,
};

const wallet = #[
    drivingLicence,
    creditCard,
    debitCard,
];

See also t.isTupleExpression(node, opts) and t.assertTupleExpression(node, opts).

AST Node TupleExpression shape:

Aliases: Expression


tupleTypeAnnotation#

t.tupleTypeAnnotation(types);
TupleTypeAnnotation

See also t.isTupleTypeAnnotation(node, opts) and t.assertTupleTypeAnnotation(node, opts).

AST Node TupleTypeAnnotation shape:

Aliases: Flow, FlowType


typeAlias#

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

See also t.isTypeAlias(node, opts) and t.assertTypeAlias(node, opts).

AST Node TypeAlias shape:

Aliases: Flow, FlowDeclaration, Statement, Declaration


typeAnnotation#

t.typeAnnotation(typeAnnotation);
TypeAnnotation

See also t.isTypeAnnotation(node, opts) and t.assertTypeAnnotation(node, opts).

AST Node TypeAnnotation shape:

Aliases: Flow


typeCastExpression#

t.typeCastExpression(expression, typeAnnotation);
TypeCastExpression

See also t.isTypeCastExpression(node, opts) and t.assertTypeCastExpression(node, opts).

AST Node TypeCastExpression shape:

Aliases: Flow, ExpressionWrapper, Expression


typeParameter#

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

See also t.isTypeParameter(node, opts) and t.assertTypeParameter(node, opts).

AST Node TypeParameter shape:

Aliases: Flow


typeParameterDeclaration#

t.typeParameterDeclaration(params);
TypeParameterDeclaration

See also t.isTypeParameterDeclaration(node, opts) and t.assertTypeParameterDeclaration(node, opts).

AST Node TypeParameterDeclaration shape:

Aliases: Flow


typeParameterInstantiation#

t.typeParameterInstantiation(params);
TypeParameterInstantiation

See also t.isTypeParameterInstantiation(node, opts) and t.assertTypeParameterInstantiation(node, opts).

AST Node TypeParameterInstantiation shape:

Aliases: Flow


typeofTypeAnnotation#

t.typeofTypeAnnotation(argument);
TypeofTypeAnnotation

See also t.isTypeofTypeAnnotation(node, opts) and t.assertTypeofTypeAnnotation(node, opts).

AST Node TypeofTypeAnnotation shape:

Aliases: Flow, FlowType


unaryExpression#

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

const t = typeof {};

const inverse = -x;

const pos = +i;

delete Employee.firstname;

See also t.isUnaryExpression(node, opts) and t.assertUnaryExpression(node, opts).

AST Node UnaryExpression shape:

  • operator: "void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof" (required)
  • argument: Expression (required)
  • prefix: boolean (default: true)

Aliases: Standardized, UnaryLike, Expression


unionTypeAnnotation#

t.unionTypeAnnotation(types);
UnionTypeAnnotation

// Flow

function eatSomething(food: 'sushi' | 'ramen') {
	// ...
}

See also t.isUnionTypeAnnotation(node, opts) and t.assertUnionTypeAnnotation(node, opts).

AST Node UnionTypeAnnotation shape:

Aliases: Flow, FlowType


updateExpression#

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

acc ++;
elems --;

//

++ acc;
-- elems;

See also t.isUpdateExpression(node, opts) and t.assertUpdateExpression(node, opts).

AST Node UpdateExpression shape:

  • operator: "++" | "--" (required)
  • argument: Expression (required)
  • prefix: boolean (default: false)

Aliases: Standardized, Expression


v8IntrinsicIdentifier#

t.v8IntrinsicIdentifier(name);
V8IntrinsicIdentifier

See also t.isV8IntrinsicIdentifier(node, opts) and t.assertV8IntrinsicIdentifier(node, opts).

AST Node V8IntrinsicIdentifier shape:

  • name: string (required)

Aliases: Miscellaneous


variableDeclaration#

t.variableDeclaration(kind, declarations);
VariableDeclaration

let nums = [100, 200, 300];

const babelRocks = true;

var foo='lorem ipsum dolor sit amet';

// Flow/Typescript
let empty:boolean;

var a,
    b=2,
    c="query",
    d;
History

| Version | Changes | | --- | --- | | v7.20.0 | kind can be "using". |

See also t.isVariableDeclaration(node, opts) and t.assertVariableDeclaration(node, opts).

AST Node VariableDeclaration shape:

  • kind: "var" | "let" | "const" | "using" | "await using" (required)
  • declarations: Array<VariableDeclarator> (required)
  • declare: boolean (default: null, excluded from builder function)

Aliases: Standardized, Statement, Declaration


variableDeclarator#

t.variableDeclarator(id, init);
VariableDeclarator

let nums = [100, 200, 300];

const babelRocks = true;

var foo='lorem ipsum dolor sit amet';

// Flow/Typescript
let empty:boolean;

var a,
    b=2,
    c="qwerty",
    d;

See also t.isVariableDeclarator(node, opts) and t.assertVariableDeclarator(node, opts).

AST Node VariableDeclarator shape:

  • id: LVal (required)
  • init: Expression (default: null)
  • definite: boolean (default: null, excluded from builder function)

Aliases: Standardized


variance#

t.variance(kind);
Variance

See also t.isVariance(node, opts) and t.assertVariance(node, opts).

AST Node Variance shape:

  • kind: "minus" | "plus" (required)

Aliases: Flow


voidTypeAnnotation#

t.voidTypeAnnotation();
VoidTypeAnnotation

See also t.isVoidTypeAnnotation(node, opts) and t.assertVoidTypeAnnotation(node, opts).

Aliases: Flow, FlowType, FlowBaseAnnotation


whileStatement#

t.whileStatement(test, body);
WhileStatement

let n = 0;
let x = 0;

while (n < 3) {
  n++;
  x += n;
}

See also t.isWhileStatement(node, opts) and t.assertWhileStatement(node, opts).

AST Node WhileStatement shape:

Aliases: Standardized, Statement, BlockParent, Loop, While, Scopable


withStatement#

t.withStatement(object, body);
WithStatement

// 'with' statement throws an error in strict mode
// so babel-parser config must include "sourceType": "script"
// for it to work
function foo() {
  const obj={a:{b:10}}
  with(obj.a){
    b=11
  }
  return obj;
}

See also t.isWithStatement(node, opts) and t.assertWithStatement(node, opts).

AST Node WithStatement shape:

Aliases: Standardized, Statement


yieldExpression#

t.yieldExpression(argument, delegate);
YieldExpression

function* g1() {
  yield 2;
  yield 3;
  yield 4;
}

function* g2() {
  yield 1;
  yield* g1();
  yield 5;
}

var iterator = g2();

console.log(iterator.next()); // { value: 1, done: false }
console.log(iterator.next()); // { value: 2, done: false }
console.log(iterator.next()); // { value: 3, done: false }
console.log(iterator.next()); // { value: 4, done: false }
console.log(iterator.next()); // { value: 5, done: false }
console.log(iterator.next()); // { value: undefined, done: true }

See also t.isYieldExpression(node, opts) and t.assertYieldExpression(node, opts).

AST Node YieldExpression shape:

  • argument: Expression (default: null)
  • delegate: boolean (default: false)

Aliases: Standardized, Expression, Terminatorless


Aliases

Accessor

Deprecated. Will be removed in Babel 8.

t.isAccessor(node);

Covered nodes:

Binary

A cover of BinaryExpression and LogicalExpression, which share the same AST shape.

t.isBinary(node);

Covered nodes:

Block

Deprecated. Will be removed in Babel 8.

t.isBlock(node);

Covered nodes:

BlockParent

A cover of AST nodes that start an execution context with new LexicalEnvironment. In other words, they define the scope of let and const declarations.

t.isBlockParent(node);

Covered nodes:

Class

A cover of ClassExpression and ClassDeclaration, which share the same AST shape.

t.isClass(node);

Covered nodes:

CompletionStatement

A statement that indicates the completion records. In other words, they define the control flow of the program, such as when should a loop break or an action throws critical errors.

t.isCompletionStatement(node);

Covered nodes:

Conditional

A cover of ConditionalExpression and IfStatement, which share the same AST shape.

t.isConditional(node);

Covered nodes:

Declaration

A cover of any Declarations.

t.isDeclaration(node);

Covered nodes:

EnumBody

A cover of Flow enum bodies.

t.isEnumBody(node);

Covered nodes:

EnumMember

A cover of Flow enum members.

t.isEnumMember(node);

Covered nodes:

ExportDeclaration

A cover of any ExportDeclarations.

t.isExportDeclaration(node);

Covered nodes:

Expression

A cover of any Expressions.

t.isExpression(node);

Covered nodes:

ExpressionWrapper

A wrapper of expression that does not have runtime semantics.

t.isExpressionWrapper(node);

Covered nodes:

Flow

A cover of AST nodes defined for Flow.

t.isFlow(node);

Covered nodes:

FlowBaseAnnotation

A cover of primary Flow type annotations.

t.isFlowBaseAnnotation(node);

Covered nodes:

FlowDeclaration

A cover of Flow declarations.

t.isFlowDeclaration(node);

Covered nodes:

FlowPredicate

A cover of Flow predicates.

t.isFlowPredicate(node);

Covered nodes:

FlowType

A cover of Flow type annotations.

t.isFlowType(node);

Covered nodes:

For

A cover of ForStatements and ForXStatements.

t.isFor(node);

Covered nodes:

ForXStatement

A cover of ForInStatements and ForOfStatements.

t.isForXStatement(node);

Covered nodes:

Function

A cover of functions and methods, the must have body and params. Note: Function is different to FunctionParent. For example, a StaticBlock is a FunctionParent but not Function.

t.isFunction(node);

Covered nodes:

FunctionParent

A cover of AST nodes that start an execution context with new VariableEnvironment. In other words, they define the scope of var declarations. FunctionParent did not include Program since Babel 7.

t.isFunctionParent(node);

Covered nodes:

Immutable

A cover of immutable objects and JSX elements. An object is immutable if no other properties can be defined once created.

t.isImmutable(node);

Covered nodes:

ImportOrExportDeclaration

History

| Version | Changes | | --- | --- | | v7.21.0 | Introduced |

A cover of ImportDeclaration and ExportDeclaration.

t.isImportOrExportDeclaration(node);

Covered nodes:

JSX

A cover of AST nodes defined for JSX.

t.isJSX(node);

Covered nodes:

LVal

A cover of left hand side expressions used in the left of assignment expressions and ForXStatements.

t.isLVal(node);

Covered nodes:

Literal

A cover of Literals, Regular Expression Literals and Template Literals.

t.isLiteral(node);

Covered nodes:

Loop

A cover of loop statements.

t.isLoop(node);

Covered nodes:

Method

A cover of object methods and class methods.

t.isMethod(node);

Covered nodes:

Miscellaneous

A cover of non-standard AST types that are sometimes useful for development.

t.isMiscellaneous(node);

Covered nodes:

ModuleDeclaration

History

| Version | Changes | | --- | --- | | v7.21.0 | Deprecated |

:::caution

Deprecated, use ImportOrExportDeclaration instead. Check out PR #15266 for migration notes.

:::

t.isModuleDeclaration(node);

Covered nodes:

ModuleSpecifier

A cover of import and export specifiers. Note: It is not the ModuleSpecifier defined in the spec.

t.isModuleSpecifier(node);

Covered nodes:

ObjectMember

A cover of members in an object literal.

t.isObjectMember(node);

Covered nodes:

Pattern

A cover of BindingPattern except Identifiers.

t.isPattern(node);

Covered nodes:

PatternLike

A cover of BindingPatterns.

t.isPatternLike(node);

Covered nodes:

Private

A cover of private class elements and private identifiers.

t.isPrivate(node);

Covered nodes:

Property

A cover of object properties and class properties.

t.isProperty(node);

Covered nodes:

Pureish

A cover of AST nodes which do not have side-effects. In other words, there is no observable behaviour changes if they are evaluated more than once.

t.isPureish(node);

Covered nodes:

Scopable

A cover of FunctionParent and BlockParent.

t.isScopable(node);

Covered nodes:

Standardized

A cover of AST nodes which are part of an official ECMAScript specification.

t.isStandardized(node);

Covered nodes:

Statement

A cover of any Statements.

t.isStatement(node);

Covered nodes:

TSBaseType

A cover of primary TypeScript type annotations.

t.isTSBaseType(node);

Covered nodes:

TSEntityName

A cover of ts entities.

t.isTSEntityName(node);

Covered nodes:

TSType

A cover of TypeScript type annotations.

t.isTSType(node);

Covered nodes:

TSTypeElement

A cover of TypeScript type declarations.

t.isTSTypeElement(node);

Covered nodes:

Terminatorless

A cover of AST nodes whose semantic will change when a line terminator is inserted between the operator and the operand.

t.isTerminatorless(node);

Covered nodes:

TypeScript

A cover of AST nodes defined for TypeScript.

t.isTypeScript(node);

Covered nodes:

UnaryLike

A cover of UnaryExpression and SpreadElement.

t.isUnaryLike(node);

Covered nodes:

UserWhitespacable

Deprecated. Will be removed in Babel 8.

t.isUserWhitespacable(node);

Covered nodes:

While

A cover of DoWhileStatement and WhileStatement, which share the same AST shape.

t.isWhile(node);

Covered nodes: