Type Parameters

Constructors

Properties

Methods

addComment addComments arrowFunctionToExpression arrowFunctionToShadowed assertAccessor assertAnyTypeAnnotation assertArgumentPlaceholder assertArrayExpression assertArrayPattern assertArrayTypeAnnotation assertArrowFunctionExpression assertAssignmentExpression assertAssignmentPattern assertAwaitExpression assertBigIntLiteral assertBinary assertBinaryExpression assertBindExpression assertBlock assertBlockParent assertBlockStatement assertBooleanLiteral assertBooleanLiteralTypeAnnotation assertBooleanTypeAnnotation assertBreakStatement assertCallExpression assertCatchClause assertClass assertClassAccessorProperty assertClassBody assertClassDeclaration assertClassExpression assertClassImplements assertClassMethod assertClassPrivateMethod assertClassPrivateProperty assertClassProperty assertCompletionStatement assertConditional assertConditionalExpression assertContinueStatement assertDebuggerStatement assertDecimalLiteral assertDeclaration assertDeclareClass assertDeclareExportAllDeclaration assertDeclareExportDeclaration assertDeclareFunction assertDeclareInterface assertDeclareModule assertDeclareModuleExports assertDeclareOpaqueType assertDeclareTypeAlias assertDeclareVariable assertDeclaredPredicate assertDecorator assertDirective assertDirectiveLiteral assertDoExpression assertDoWhileStatement assertEmptyStatement assertEmptyTypeAnnotation assertEnumBody assertEnumBooleanBody assertEnumBooleanMember assertEnumDeclaration assertEnumDefaultedMember assertEnumMember assertEnumNumberBody assertEnumNumberMember assertEnumStringBody assertEnumStringMember assertEnumSymbolBody assertExistsTypeAnnotation assertExportAllDeclaration assertExportDeclaration assertExportDefaultDeclaration assertExportDefaultSpecifier assertExportNamedDeclaration assertExportNamespaceSpecifier assertExportSpecifier assertExpression assertExpressionStatement assertExpressionWrapper assertFile assertFlow assertFlowBaseAnnotation assertFlowDeclaration assertFlowPredicate assertFlowType assertFor assertForInStatement assertForOfStatement assertForStatement assertForXStatement assertFunction assertFunctionDeclaration assertFunctionExpression assertFunctionParent assertFunctionTypeAnnotation assertFunctionTypeParam assertGenericTypeAnnotation assertIdentifier assertIfStatement assertImmutable assertImport assertImportAttribute assertImportDeclaration assertImportDefaultSpecifier assertImportNamespaceSpecifier assertImportSpecifier assertIndexedAccessType assertInferredPredicate assertInterfaceDeclaration assertInterfaceExtends assertInterfaceTypeAnnotation assertInterpreterDirective assertIntersectionTypeAnnotation assertJSX assertJSXAttribute assertJSXClosingElement assertJSXClosingFragment assertJSXElement assertJSXEmptyExpression assertJSXExpressionContainer assertJSXFragment assertJSXIdentifier assertJSXMemberExpression assertJSXNamespacedName assertJSXOpeningElement assertJSXOpeningFragment assertJSXSpreadAttribute assertJSXSpreadChild assertJSXText assertLVal assertLabeledStatement assertLiteral assertLogicalExpression assertLoop assertMemberExpression assertMetaProperty assertMethod assertMiscellaneous assertMixedTypeAnnotation assertModuleDeclaration assertModuleExpression assertModuleSpecifier assertNewExpression assertNoop assertNullLiteral assertNullLiteralTypeAnnotation assertNullableTypeAnnotation assertNumberLiteral assertNumberLiteralTypeAnnotation assertNumberTypeAnnotation assertNumericLiteral assertObjectExpression assertObjectMember assertObjectMethod assertObjectPattern assertObjectProperty assertObjectTypeAnnotation assertObjectTypeCallProperty assertObjectTypeIndexer assertObjectTypeInternalSlot assertObjectTypeProperty assertObjectTypeSpreadProperty assertOpaqueType assertOptionalCallExpression assertOptionalIndexedAccessType assertOptionalMemberExpression assertParenthesizedExpression assertPattern assertPatternLike assertPipelineBareFunction assertPipelinePrimaryTopicReference assertPipelineTopicExpression assertPlaceholder assertPrivate assertPrivateName assertProgram assertProperty assertPureish assertQualifiedTypeIdentifier assertRecordExpression assertRegExpLiteral assertRegexLiteral assertRestElement assertRestProperty assertReturnStatement assertScopable assertSequenceExpression assertSpreadElement assertSpreadProperty assertStandardized assertStatement assertStaticBlock assertStringLiteral assertStringLiteralTypeAnnotation assertStringTypeAnnotation assertSuper assertSwitchCase assertSwitchStatement assertSymbolTypeAnnotation assertTSAnyKeyword assertTSArrayType assertTSAsExpression assertTSBaseType assertTSBigIntKeyword assertTSBooleanKeyword assertTSCallSignatureDeclaration assertTSConditionalType assertTSConstructSignatureDeclaration assertTSConstructorType assertTSDeclareFunction assertTSDeclareMethod assertTSEntityName assertTSEnumDeclaration assertTSEnumMember assertTSExportAssignment assertTSExpressionWithTypeArguments assertTSExternalModuleReference assertTSFunctionType assertTSImportEqualsDeclaration assertTSImportType assertTSIndexSignature assertTSIndexedAccessType assertTSInferType assertTSInstantiationExpression assertTSInterfaceBody assertTSInterfaceDeclaration assertTSIntersectionType assertTSIntrinsicKeyword assertTSLiteralType assertTSMappedType assertTSMethodSignature assertTSModuleBlock assertTSModuleDeclaration assertTSNamedTupleMember assertTSNamespaceExportDeclaration assertTSNeverKeyword assertTSNonNullExpression assertTSNullKeyword assertTSNumberKeyword assertTSObjectKeyword assertTSOptionalType assertTSParameterProperty assertTSParenthesizedType assertTSPropertySignature assertTSQualifiedName assertTSRestType assertTSSatisfiesExpression assertTSStringKeyword assertTSSymbolKeyword assertTSThisType assertTSTupleType assertTSType assertTSTypeAliasDeclaration assertTSTypeAnnotation assertTSTypeAssertion assertTSTypeElement assertTSTypeLiteral assertTSTypeOperator assertTSTypeParameter assertTSTypeParameterDeclaration assertTSTypeParameterInstantiation assertTSTypePredicate assertTSTypeQuery assertTSTypeReference assertTSUndefinedKeyword assertTSUnionType assertTSUnknownKeyword assertTSVoidKeyword assertTaggedTemplateExpression assertTemplateElement assertTemplateLiteral assertTerminatorless assertThisExpression assertThisTypeAnnotation assertThrowStatement assertTopicReference assertTryStatement assertTupleExpression assertTupleTypeAnnotation assertTypeAlias assertTypeAnnotation assertTypeCastExpression assertTypeParameter assertTypeParameterDeclaration assertTypeParameterInstantiation assertTypeScript assertTypeofTypeAnnotation assertUnaryExpression assertUnaryLike assertUnionTypeAnnotation assertUpdateExpression assertUserWhitespacable assertV8IntrinsicIdentifier assertVariableDeclaration assertVariableDeclarator assertVariance assertVoidTypeAnnotation assertWhile assertWhileStatement assertWithStatement assertYieldExpression baseTypeStrictlyMatches buildCodeFrameError call canHaveVariableDeclarationOrExpression canSwapBetweenExpressionAndStatement couldBeBaseType debug ensureBlock equals evaluate evaluateTruthy find findParent get getAllNextSiblings getAllPrevSiblings getAncestry getBindingIdentifierPaths getBindingIdentifiers getCompletionRecords getData getDeepestCommonAncestorFrom getEarliestCommonAncestorFrom getFunctionParent getNextSibling getOpposite getOuterBindingIdentifierPaths getOuterBindingIdentifiers getPathLocation getPrevSibling getScope getSibling getSource getStatementParent getTypeAnnotation has hasNode hoist inType insertAfter insertBefore is isAccessor isAncestor isAnyTypeAnnotation isArgumentPlaceholder isArrayExpression isArrayPattern isArrayTypeAnnotation isArrowFunctionExpression isAssignmentExpression isAssignmentPattern isAwaitExpression isBaseType isBigIntLiteral isBinary isBinaryExpression isBindExpression isBindingIdentifier isBlacklisted isBlock isBlockParent isBlockScoped isBlockStatement isBooleanLiteral isBooleanLiteralTypeAnnotation isBooleanTypeAnnotation isBreakStatement isCallExpression isCatchClause isClass isClassAccessorProperty isClassBody isClassDeclaration isClassExpression isClassImplements isClassMethod isClassPrivateMethod isClassPrivateProperty isClassProperty isCompletionRecord isCompletionStatement isConditional isConditionalExpression isConstantExpression isContinueStatement isDebuggerStatement isDecimalLiteral isDeclaration isDeclareClass isDeclareExportAllDeclaration isDeclareExportDeclaration isDeclareFunction isDeclareInterface isDeclareModule isDeclareModuleExports isDeclareOpaqueType isDeclareTypeAlias isDeclareVariable isDeclaredPredicate isDecorator isDenylisted isDescendant isDirective isDirectiveLiteral isDoExpression isDoWhileStatement isEmptyStatement isEmptyTypeAnnotation isEnumBody isEnumBooleanBody isEnumBooleanMember isEnumDeclaration isEnumDefaultedMember isEnumMember isEnumNumberBody isEnumNumberMember isEnumStringBody isEnumStringMember isEnumSymbolBody isExistentialTypeParam isExistsTypeAnnotation isExportAllDeclaration isExportDeclaration isExportDefaultDeclaration isExportDefaultSpecifier isExportNamedDeclaration isExportNamespaceSpecifier isExportSpecifier isExpression isExpressionStatement isExpressionWrapper isFile isFlow isFlowBaseAnnotation isFlowDeclaration isFlowPredicate isFlowType isFor isForAwaitStatement isForInStatement isForOfStatement isForStatement isForXStatement isFunction isFunctionDeclaration isFunctionExpression isFunctionParent isFunctionTypeAnnotation isFunctionTypeParam isGenerated isGenericType isGenericTypeAnnotation isIdentifier isIfStatement isImmutable isImport isImportAttribute isImportDeclaration isImportDefaultSpecifier isImportNamespaceSpecifier isImportSpecifier isInStrictMode isIndexedAccessType isInferredPredicate isInterfaceDeclaration isInterfaceExtends isInterfaceTypeAnnotation isInterpreterDirective isIntersectionTypeAnnotation isJSX isJSXAttribute isJSXClosingElement isJSXClosingFragment isJSXElement isJSXEmptyExpression isJSXExpressionContainer isJSXFragment isJSXIdentifier isJSXMemberExpression isJSXNamespacedName isJSXOpeningElement isJSXOpeningFragment isJSXSpreadAttribute isJSXSpreadChild isJSXText isLVal isLabeledStatement isLiteral isLogicalExpression isLoop isMemberExpression isMetaProperty isMethod isMiscellaneous isMixedTypeAnnotation isModuleDeclaration isModuleExpression isModuleSpecifier isNewExpression isNodeType isNoop isNullLiteral isNullLiteralTypeAnnotation isNullableTypeAnnotation isNumberLiteral isNumberLiteralTypeAnnotation isNumberTypeAnnotation isNumericLiteral isNumericLiteralTypeAnnotation isObjectExpression isObjectMember isObjectMethod isObjectPattern isObjectProperty isObjectTypeAnnotation isObjectTypeCallProperty isObjectTypeIndexer isObjectTypeInternalSlot isObjectTypeProperty isObjectTypeSpreadProperty isOpaqueType isOptionalCallExpression isOptionalIndexedAccessType isOptionalMemberExpression isParenthesizedExpression isPattern isPatternLike isPipelineBareFunction isPipelinePrimaryTopicReference isPipelineTopicExpression isPlaceholder isPrivate isPrivateName isProgram isProperty isPure isPureish isQualifiedTypeIdentifier isRecordExpression isReferenced isReferencedIdentifier isReferencedMemberExpression isRegExpLiteral isRegexLiteral isRestElement isRestProperty isReturnStatement isScopable isScope isSequenceExpression isSpreadElement isSpreadProperty isStandardized isStatement isStatementOrBlock isStatic isStaticBlock isStringLiteral isStringLiteralTypeAnnotation isStringTypeAnnotation isSuper isSwitchCase isSwitchStatement isSymbolTypeAnnotation isTSAnyKeyword isTSArrayType isTSAsExpression isTSBaseType isTSBigIntKeyword isTSBooleanKeyword isTSCallSignatureDeclaration isTSConditionalType isTSConstructSignatureDeclaration isTSConstructorType isTSDeclareFunction isTSDeclareMethod isTSEntityName isTSEnumDeclaration isTSEnumMember isTSExportAssignment isTSExpressionWithTypeArguments isTSExternalModuleReference isTSFunctionType isTSImportEqualsDeclaration isTSImportType isTSIndexSignature isTSIndexedAccessType isTSInferType isTSInstantiationExpression isTSInterfaceBody isTSInterfaceDeclaration isTSIntersectionType isTSIntrinsicKeyword isTSLiteralType isTSMappedType isTSMethodSignature isTSModuleBlock isTSModuleDeclaration isTSNamedTupleMember isTSNamespaceExportDeclaration isTSNeverKeyword isTSNonNullExpression isTSNullKeyword isTSNumberKeyword isTSObjectKeyword isTSOptionalType isTSParameterProperty isTSParenthesizedType isTSPropertySignature isTSQualifiedName isTSRestType isTSSatisfiesExpression isTSStringKeyword isTSSymbolKeyword isTSThisType isTSTupleType isTSType isTSTypeAliasDeclaration isTSTypeAnnotation isTSTypeAssertion isTSTypeElement isTSTypeLiteral isTSTypeOperator isTSTypeParameter isTSTypeParameterDeclaration isTSTypeParameterInstantiation isTSTypePredicate isTSTypeQuery isTSTypeReference isTSUndefinedKeyword isTSUnionType isTSUnknownKeyword isTSVoidKeyword isTaggedTemplateExpression isTemplateElement isTemplateLiteral isTerminatorless isThisExpression isThisTypeAnnotation isThrowStatement isTopicReference isTryStatement isTupleExpression isTupleTypeAnnotation isTypeAlias isTypeAnnotation isTypeCastExpression isTypeParameter isTypeParameterDeclaration isTypeParameterInstantiation isTypeScript isTypeofTypeAnnotation isUnaryExpression isUnaryLike isUnionTypeAnnotation isUpdateExpression isUser isUserWhitespacable isV8IntrinsicIdentifier isVar isVariableDeclaration isVariableDeclarator isVariance isVoidTypeAnnotation isWhile isWhileStatement isWithStatement isYieldExpression isnt matchesPattern popContext pushContainer pushContext referencesImport remove replaceExpressionWithStatements replaceInline replaceWith replaceWithMultiple replaceWithSourceString requeue resolve resync set setContext setData setScope shareCommentsWithSiblings skip skipKey stop toComputedKey traverse unshiftContainer unwrapFunctionEnvironment updateSiblingKeys visit willIMaybeExecuteBefore get

Constructors

Properties

container: null | Node | Node[]
context: TraversalContext<unknown>
contexts: TraversalContext<unknown>[]
data: Record<string | symbol, unknown>
hub: Hub
inList: boolean
key: null | string | number
listKey: null | string
node: T
opts: any
parent: Node
parentKey: string
parentPath: T extends Program
    ? null
    : NodePath<Node>
removed: boolean
scope: Scope
shouldSkip: boolean
shouldStop: boolean
skipKeys: null | Record<string, boolean>
state: any
type: T extends Node
    ? T<T>["type"]
    : T extends undefined | null
        ? undefined
        : undefined | "CatchClause" | "ClassBody" | "Identifier" | "Program" | "SpreadElement" | "Super" | "SwitchCase" | "TemplateElement" | "VariableDeclarator" | "ArrayExpression" | "ArrowFunctionExpression" | "AssignmentExpression" | "AwaitExpression" | "BinaryExpression" | "CallExpression" | "ClassExpression" | "ConditionalExpression" | "FunctionExpression" | "ImportExpression" | "LogicalExpression" | "MemberExpression" | "MetaProperty" | "NewExpression" | "ObjectExpression" | "SequenceExpression" | "TaggedTemplateExpression" | "TemplateLiteral" | "ThisExpression" | "UnaryExpression" | "UpdateExpression" | "YieldExpression" | "ClassDeclaration" | "FunctionDeclaration" | "ImportDeclaration" | "ExportNamedDeclaration" | "ExportDefaultDeclaration" | "ExportAllDeclaration" | "ImportSpecifier" | "ImportDefaultSpecifier" | "ImportNamespaceSpecifier" | "ExportSpecifier" | "ObjectPattern" | "ArrayPattern" | "RestElement" | "AssignmentPattern" | "ExpressionStatement" | "BlockStatement" | "StaticBlock" | "EmptyStatement" | "DebuggerStatement" | "WithStatement" | "ReturnStatement" | "LabeledStatement" | "BreakStatement" | "ContinueStatement" | "IfStatement" | "SwitchStatement" | "ThrowStatement" | "TryStatement" | "WhileStatement" | "DoWhileStatement" | "ForStatement" | "ForInStatement" | "ForOfStatement" | "VariableDeclaration" | "AnyTypeAnnotation" | "ArgumentPlaceholder" | "ArrayTypeAnnotation" | "BigIntLiteral" | "BindExpression" | "BooleanLiteral" | "BooleanLiteralTypeAnnotation" | "BooleanTypeAnnotation" | "ClassAccessorProperty" | "ClassImplements" | "ClassMethod" | "ClassPrivateMethod" | "ClassPrivateProperty" | "ClassProperty" | "DecimalLiteral" | "DeclareClass" | "DeclareExportAllDeclaration" | "DeclareExportDeclaration" | "DeclareFunction" | "DeclareInterface" | "DeclareModule" | "DeclareModuleExports" | "DeclareOpaqueType" | "DeclareTypeAlias" | "DeclareVariable" | "DeclaredPredicate" | "Decorator" | "Directive" | "DirectiveLiteral" | "DoExpression" | "EmptyTypeAnnotation" | "EnumBooleanBody" | "EnumBooleanMember" | "EnumDeclaration" | "EnumDefaultedMember" | "EnumNumberBody" | "EnumNumberMember" | "EnumStringBody" | "EnumStringMember" | "EnumSymbolBody" | "ExistsTypeAnnotation" | "ExportDefaultSpecifier" | "ExportNamespaceSpecifier" | "File" | "FunctionTypeAnnotation" | "FunctionTypeParam" | "GenericTypeAnnotation" | "Import" | "ImportAttribute" | "IndexedAccessType" | "InferredPredicate" | "InterfaceDeclaration" | "InterfaceExtends" | "InterfaceTypeAnnotation" | "InterpreterDirective" | "IntersectionTypeAnnotation" | "JSXAttribute" | "JSXClosingElement" | "JSXClosingFragment" | "JSXElement" | "JSXEmptyExpression" | "JSXExpressionContainer" | "JSXFragment" | "JSXIdentifier" | "JSXMemberExpression" | "JSXNamespacedName" | "JSXOpeningElement" | "JSXOpeningFragment" | "JSXSpreadAttribute" | "JSXSpreadChild" | "JSXText" | "MixedTypeAnnotation" | "ModuleExpression" | "Noop" | "NullLiteral" | "NullLiteralTypeAnnotation" | "NullableTypeAnnotation" | "NumberLiteral" | "NumberLiteralTypeAnnotation" | "NumberTypeAnnotation" | "NumericLiteral" | "ObjectMethod" | "ObjectProperty" | "ObjectTypeAnnotation" | "ObjectTypeCallProperty" | "ObjectTypeIndexer" | "ObjectTypeInternalSlot" | "ObjectTypeProperty" | "ObjectTypeSpreadProperty" | "OpaqueType" | "OptionalCallExpression" | "OptionalIndexedAccessType" | "OptionalMemberExpression" | "ParenthesizedExpression" | "PipelineBareFunction" | "PipelinePrimaryTopicReference" | "PipelineTopicExpression" | "Placeholder" | "PrivateName" | "QualifiedTypeIdentifier" | "RecordExpression" | "RegExpLiteral" | "RegexLiteral" | "RestProperty" | "SpreadProperty" | "StringLiteral" | "StringLiteralTypeAnnotation" | "StringTypeAnnotation" | "SymbolTypeAnnotation" | "TSAnyKeyword" | "TSArrayType" | "TSAsExpression" | "TSBigIntKeyword" | "TSBooleanKeyword" | "TSCallSignatureDeclaration" | "TSConditionalType" | "TSConstructSignatureDeclaration" | "TSConstructorType" | "TSDeclareFunction" | "TSDeclareMethod" | "TSEnumDeclaration" | "TSEnumMember" | "TSExportAssignment" | "TSExpressionWithTypeArguments" | "TSExternalModuleReference" | "TSFunctionType" | "TSImportEqualsDeclaration" | "TSImportType" | "TSIndexSignature" | "TSIndexedAccessType" | "TSInferType" | "TSInstantiationExpression" | "TSInterfaceBody" | "TSInterfaceDeclaration" | "TSIntersectionType" | "TSIntrinsicKeyword" | "TSLiteralType" | "TSMappedType" | "TSMethodSignature" | "TSModuleBlock" | "TSModuleDeclaration" | "TSNamedTupleMember" | "TSNamespaceExportDeclaration" | "TSNeverKeyword" | "TSNonNullExpression" | "TSNullKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSOptionalType" | "TSParameterProperty" | "TSParenthesizedType" | "TSPropertySignature" | "TSQualifiedName" | "TSRestType" | "TSSatisfiesExpression" | "TSStringKeyword" | "TSSymbolKeyword" | "TSThisType" | "TSTupleType" | "TSTypeAliasDeclaration" | "TSTypeAnnotation" | "TSTypeAssertion" | "TSTypeLiteral" | "TSTypeOperator" | "TSTypeParameter" | "TSTypeParameterDeclaration" | "TSTypeParameterInstantiation" | "TSTypePredicate" | "TSTypeQuery" | "TSTypeReference" | "TSUndefinedKeyword" | "TSUnionType" | "TSUnknownKeyword" | "TSVoidKeyword" | "ThisTypeAnnotation" | "TopicReference" | "TupleExpression" | "TupleTypeAnnotation" | "TypeAlias" | "TypeAnnotation" | "TypeCastExpression" | "TypeParameter" | "TypeParameterDeclaration" | "TypeParameterInstantiation" | "TypeofTypeAnnotation" | "UnionTypeAnnotation" | "V8IntrinsicIdentifier" | "Variance" | "VoidTypeAnnotation"
typeAnnotation: object

Methods

  • Parameters

    Returns void

  • Give node comments of the specified type.

    Parameters

    Returns void

  • Convert a given arrow function into a normal ES5 function expression.

    Parameters

    • Optional __namedParameters: {
          allowInsertArrow?: boolean;
          allowInsertArrowWithRest?: boolean;
          noNewArrows?: boolean;
          specCompliant?: boolean;
      }
      • Optional allowInsertArrow?: boolean
      • Optional allowInsertArrowWithRest?: boolean
      • Optional noNewArrows?: boolean
      • Optional specCompliant?: boolean

    Returns NodePath<CallExpression | FunctionDeclaration | FunctionExpression>

  • Returns void

    Deprecated

    Use arrowFunctionToExpression

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<ArrayPattern>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Binary>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Block>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<BlockParent>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<CatchClause>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Class>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<ClassBody>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<ClassMethod>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Conditional>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Declaration>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<DeclareClass>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Decorator>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Directive>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<DoExpression>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<EnumBody>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<EnumMember>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Expression>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<File>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Flow>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<FlowType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<For>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<ForStatement>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Function>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Identifier>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<IfStatement>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Immutable>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Import>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<JSX>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<JSXAttribute>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<JSXElement>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<JSXFragment>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<JSXText>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<LVal>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Literal>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Loop>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<MetaProperty>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Method>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Noop>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<NullLiteral>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<NumberLiteral>

    Deprecated

    Use assertNumericLiteral

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<ObjectMember>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<ObjectMethod>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<OpaqueType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Pattern>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<PatternLike>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Placeholder>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Private>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<PrivateName>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Program>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Property>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Pureish>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<RegexLiteral>

    Deprecated

    Use assertRegExpLiteral

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<RestElement>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<RestProperty>

    Deprecated

    Use assertRestElement

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Scopable>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<SpreadProperty>

    Deprecated

    Use assertSpreadElement

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Standardized>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Statement>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<StaticBlock>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Super>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<SwitchCase>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSAnyKeyword>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSArrayType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSBaseType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSEntityName>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSEnumMember>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSImportType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSInferType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSMappedType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSRestType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSThisType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSTupleType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSTypeQuery>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TSUnionType>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TryStatement>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TypeAlias>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<TypeScript>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<UnaryLike>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<Variance>

  • Parameters

    • Optional opts: object

    Returns asserts this is NodePath<While>

  • Parameters

    Returns boolean

  • Parameters

    • msg: string
    • Optional Error: ErrorConstructor

    Returns Error

  • Parameters

    • key: string

    Returns boolean

  • This checks whether or not we're in one of the following positions:

    for (KEY in right); for (KEY;;);

    This is because these spots allow VariableDeclarations AND normal expressions so we need to tell the path replacement that it's ok to replace this with an expression.

    Returns boolean

  • This checks whether we are swapping an arrow function's body between an expression and a block statement (or vice versa).

    This is because arrow functions may implicitly return an expression, which is the same as containing a block statement.

    Parameters

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • buildMessage: (() => string)
        • (): string
        • Returns string

    Returns void

  • Check whether the path node key strict equals value.

    Parameters

    • key: string
    • value: any

    Returns boolean

  • Walk the input node and statically evaluate it.

    Returns an object in the form { confident, value, deopt }. confident indicates whether or not we had to drop out of evaluating the expression because of hitting an unknown node that we couldn't confidently find the value of, in which case deopt is the path of said node.

    Example:

    t.evaluate(parse("5 + 5")) // { confident: true, value: 10 } t.evaluate(parse("!true")) // { confident: true, value: false } t.evaluate(parse("foo + foo")) // { confident: false, value: undefined, deopt: NodePath }

    Returns {
        confident: boolean;
        deopt?: NodePath<Node>;
        value: any;
    }

  • Walk the input node and statically evaluate if it's truthy.

    Returning true when we're sure that the expression will evaluate to a truthy value, false if we're sure that it will evaluate to a falsy value and undefined if we aren't sure. Because of this please do not rely on coercion when using this method and check with === if it's false.

    Returns undefined | boolean

  • Starting at current NodePath and going up the tree, return the first NodePath that causes the provided callback to return a truthy value, or null if the callback never returns a truthy value.

    Parameters

    • callback: ((path) => boolean)
        • (path): boolean
        • Parameters

          Returns boolean

    Returns null | NodePath<Node>

  • Starting at the parent path of the current NodePath and going up the tree, return the first NodePath that causes the provided callback to return a truthy value, or null if the callback never returns a truthy value.

    Parameters

    • callback: ((path) => boolean)
        • (path): boolean
        • Parameters

          Returns boolean

    Returns null | NodePath<Node>

  • Returns NodePath<Node>[]

  • Returns NodePath<Node>[]

  • Build an array of node paths containing the entire ancestry of the current node path.

    NOTE: The current node path is included in this.

    Returns [NodePath<T>, ...NodePath<Node>[]]

  • Parameters

    • duplicates: true

    Returns Record<string, Identifier[]>

  • Parameters

    • Optional duplicates: false

    Returns Record<string, Identifier>

  • Parameters

    • Optional duplicates: boolean

    Returns Record<string, Identifier | Identifier[]>

  • Returns NodePath<Node>[]

  • Parameters

    • key: string | symbol
    • Optional def: any

    Returns any

  • Get the deepest common ancestor and then from it, get the earliest relationship path to that ancestor.

    Earliest is defined as being "before" all the other nodes in terms of list container position and visiting key.

    Parameters

    Returns NodePath<Node>

  • Get the parent function of the current path.

    Returns null | NodePath<Function>

  • Returns null | NodePath<Node>

  • Parameters

    • duplicates: true

    Returns Record<string, Identifier[]>

  • Parameters

    • Optional duplicates: false

    Returns Record<string, Identifier>

  • Parameters

    • Optional duplicates: boolean

    Returns Record<string, Identifier | Identifier[]>

  • Returns string

  • Parameters

    Returns Scope

  • Parameters

    • key: string | number

    Returns NodePath<Node>

  • Get the source code associated with this node.

    Returns string

  • Walk up the tree until we hit a parent node path in a list.

    Returns null | NodePath<Statement>

  • Infer the type of the current NodePath.

    Returns FlowType | TSType

  • Check whether we have the input key. If the key references an array then we check if the array has any items, otherwise we just check if it's falsy.

    Parameters

    • key: string

    Returns boolean

  • Returns this is NodePath<Exclude<T, undefined | null>>

  • Hoist the current node to the highest scope possible and return a UID referencing it.

    Parameters

    Returns void

  • Parameters

    • Rest ...candidateTypes: string[]

    Returns boolean

  • Insert the provided nodes after the current one. When inserting nodes after an expression, ensure that the completion record is correct by pushing the current node.

    Type Parameters

    Parameters

    Returns NodePaths<Nodes>

  • Alias of has.

    Parameters

    • key: string

    Returns boolean

  • A helper to find if this path is an ancestor of maybeDescendant

    Parameters

    Returns boolean

  • Parameters

    • baseName: string
    • Optional soft: boolean

    Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Binary>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Identifier>

  • Returns boolean

    Deprecated

    will be removed in Babel 8

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Block>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Class>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<ClassBody>

  • Check whether the current path references a completion record

    Parameters

    • Optional allowInsideFunction: boolean

    Returns boolean

  • Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Decorator>

  • Returns boolean

  • A helper to find if this path is a descendant of maybeAncestor

    Parameters

    Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Directive>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<EnumBody>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<File>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Flow>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<FlowType>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<For>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Function>

  • Parameters

    • Optional opts: object

    Returns boolean

  • Parameters

    • genericName: string

    Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Immutable>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Import>

  • Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<JSX>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<JSXText>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<LVal>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Literal>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Loop>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Method>

  • Check the type against our stored internal type of the node. This is handy when a node has been removed yet we still internally know the type and need it to calculate node replacement.

    Parameters

    • type: string

    Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Noop>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<NumberLiteral>

    Deprecated

    Use isNumericLiteral

  • Parameters

    • Optional opts: object

    Returns void

    Deprecated

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Pattern>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Private>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Program>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Property>

  • Parameters

    • Optional opts: object

    Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Pureish>

  • Parameters

    • Optional opts: object

    Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<RegexLiteral>

    Deprecated

    Use isRegExpLiteral

  • Parameters

    • Optional opts: object

    Returns this is NodePath<RestProperty>

    Deprecated

    Use isRestElement

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Scopable>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Statement>

  • Check whether or not the current key allows either a single statement or block statement so we can explode it if necessary.

    Returns boolean

  • Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Super>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<TSType>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<TypeAlias>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<UnaryLike>

  • Parameters

    • Optional opts: object

    Returns boolean

  • Parameters

    • Optional opts: object

    Returns this is NodePath<Variance>

  • Parameters

    • Optional opts: object

    Returns this is NodePath<While>

  • Opposite of has.

    Parameters

    • key: string

    Returns boolean

  • Match the current node if it matches the provided pattern.

    For example, given the match React.createClass it would match the parsed nodes of React.createClass and React["createClass"].

    Parameters

    • pattern: string
    • Optional allowPartial: boolean

    Returns boolean

  • Returns void

  • Insert child nodes at the end of the current node.

    Type Parameters

    Parameters

    • this: NodePath<T>
    • listKey: K

      The key at which the child nodes are stored (usually body).

    • nodes: Nodes

      the nodes to insert.

    Returns NodePaths<Nodes>

  • Parameters

    Returns void

  • Check if the currently assigned path references the importName of moduleSource.

    Parameters

    • moduleSource: string
    • importName: string

    Returns boolean

  • Returns void

  • Replace the current node with another.

    Type Parameters

    Parameters

    Returns [NodePath<R>]

  • Type Parameters

    Parameters

    • replacementPath: R

    Returns [R]

  • Replace a node with an array of multiple. This method performs the following steps:

    • Inherit the comments of first provided node with that of the current node.
    • Insert the provided nodes after the current node.
    • Remove the current node.

    Type Parameters

    Parameters

    Returns NodePaths<Nodes>

  • Parse a string as an expression and replace the current node with the result.

    NOTE: This is typically not a good idea to use. Building source strings when transforming ASTs is an antipattern and SHOULD NOT be encouraged. Even if it's easier to use, your transforms will be extremely brittle.

    Parameters

    • replacement: string

    Returns [NodePath<Node>]

  • Parameters

    Returns void

  • Parameters

    • Optional dangerous: boolean
    • Optional resolved: NodePath<Node>[]

    Returns NodePath<Node>

  • Here we resync the node paths key and container. If they've changed according to what we have stored internally then we attempt to resync by crawling and looking for the new values.

    Returns void

  • Parameters

    • key: string
    • node: any

    Returns void

  • Parameters

    Returns this

  • Parameters

    • key: string | symbol
    • val: any

    Returns any

  • Returns void

  • Share comments amongst siblings.

    Returns void

  • Returns void

  • Parameters

    • key: string

    Returns void

  • Returns void

  • Type Parameters

    • T

    Parameters

    Returns void

  • Parameters

    Returns void

  • Insert child nodes at the start of the current node.

    Type Parameters

    Parameters

    • this: NodePath<T>
    • listKey: K

      The key at which the child nodes are stored (usually body).

    • nodes: Nodes

      the nodes to insert.

    Returns NodePaths<Nodes>

  • Given an arbitrary function, process its content as if it were an arrow function, moving references to "this", "arguments", "super", and such into the function's parent scope. This method is useful if you have wrapped some set of items in an IIFE or other function, but want "this", "arguments", and super" to continue behaving as expected.

    Returns void

  • Update all sibling node paths after fromIndex by incrementBy.

    Parameters

    • fromIndex: number
    • incrementBy: number

    Returns void

  • Returns boolean

  • Check if the current path will maybe execute before another path

    Parameters

    Returns boolean

  • Type Parameters

    • C extends Node
    • K extends string | number | symbol

    Parameters

    Returns NodePath<C[K]>

  • Type Parameters

    • C extends Node
    • L extends string | number | symbol

    Parameters

    • opts: {
          container: C;
          hub?: HubInterface;
          key: number;
          listKey: L;
          parent: Node;
          parentPath: null | NodePath<Node>;
      }

    Returns C[L] extends (undefined | null | Node)[]
        ? NodePath<any[any][number]>
        : never