@babel/traverse 8.0.0-beta.0 → 8.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -221,13 +221,13 @@ interface HubInterface {
221
221
  getCode(): string | void;
222
222
  getScope(): Scope | void;
223
223
  addHelper(name: string): any;
224
- buildError(node: Node, msg: string, Error: new () => Error): Error;
224
+ buildError(node: Node, msg: string, Error: new (msg: string) => Error): Error;
225
225
  }
226
226
  declare class Hub implements HubInterface {
227
227
  getCode(): void;
228
228
  getScope(): void;
229
229
  addHelper(): void;
230
- buildError(node: Node, msg: string, Error?: TypeErrorConstructor): Error;
230
+ buildError(node: Node, msg: string, Error?: new (msg: string) => Error): Error;
231
231
  }
232
232
 
233
233
  declare class TraversalContext<S = unknown> {
@@ -545,6 +545,7 @@ interface ExplVisitorBase<S> {
545
545
  VariableDeclaration?: ExplVisitNode<S, t.VariableDeclaration>;
546
546
  VariableDeclarator?: ExplVisitNode<S, t.VariableDeclarator>;
547
547
  Variance?: ExplVisitNode<S, t.Variance>;
548
+ VoidPattern?: ExplVisitNode<S, t.VoidPattern>;
548
549
  VoidTypeAnnotation?: ExplVisitNode<S, t.VoidTypeAnnotation>;
549
550
  WhileStatement?: ExplVisitNode<S, t.WhileStatement>;
550
551
  WithStatement?: ExplVisitNode<S, t.WithStatement>;
@@ -806,6 +807,7 @@ interface VisitorBaseNodes<S> {
806
807
  VariableDeclaration?: VisitNode<S, t.VariableDeclaration>;
807
808
  VariableDeclarator?: VisitNode<S, t.VariableDeclarator>;
808
809
  Variance?: VisitNode<S, t.Variance>;
810
+ VoidPattern?: VisitNode<S, t.VoidPattern>;
809
811
  VoidTypeAnnotation?: VisitNode<S, t.VoidTypeAnnotation>;
810
812
  WhileStatement?: VisitNode<S, t.WhileStatement>;
811
813
  WithStatement?: VisitNode<S, t.WithStatement>;
@@ -834,6 +836,7 @@ interface VisitorBaseAliases<S> {
834
836
  For?: VisitNode<S, t.For>;
835
837
  ForXStatement?: VisitNode<S, t.ForXStatement>;
836
838
  Function?: VisitNode<S, t.Function>;
839
+ FunctionParameter?: VisitNode<S, t.FunctionParameter>;
837
840
  FunctionParent?: VisitNode<S, t.FunctionParent>;
838
841
  Immutable?: VisitNode<S, t.Immutable>;
839
842
  ImportOrExportDeclaration?: VisitNode<S, t.ImportOrExportDeclaration>;
@@ -962,14 +965,7 @@ declare function couldBeBaseType(this: NodePath_Final, name: string): boolean;
962
965
  declare function baseTypeStrictlyMatches(this: NodePath_Final, rightArg: NodePath_Final): boolean;
963
966
  declare function isGenericType(this: NodePath_Final, genericName: string): boolean;
964
967
 
965
- /**
966
- * Replace a node with an array of multiple. This method performs the following steps:
967
- *
968
- * - Inherit the comments of first provided node with that of the current node.
969
- * - Insert the provided nodes after the current node.
970
- * - Remove the current node.
971
- */
972
- declare function replaceWithMultiple(this: NodePath_Final, nodes: t.Node | t.Node[]): NodePath_Final[];
968
+ declare function replaceWithMultiple<Nodes extends NodeOrNodeList<t.Node>>(this: NodePath_Final, nodes: Nodes): NodePaths<Nodes>;
973
969
  /**
974
970
  * Parse a string as an expression and replace the current node with the result.
975
971
  *
@@ -989,7 +985,7 @@ declare function replaceWith<R extends NodePath_Final>(this: NodePath_Final, rep
989
985
  * extremely important to retain original semantics.
990
986
  */
991
987
  declare function replaceExpressionWithStatements(this: NodePath_Final, nodes: Array<t.Statement>): (NodePath<t.BlockStatement> | NodePath<t.BreakStatement> | NodePath<t.ClassDeclaration> | NodePath<t.ContinueStatement> | NodePath<t.DebuggerStatement> | NodePath<t.DeclareClass> | NodePath<t.DeclareExportAllDeclaration> | NodePath<t.DeclareExportDeclaration> | NodePath<t.DeclareFunction> | NodePath<t.DeclareInterface> | NodePath<t.DeclareModule> | NodePath<t.DeclareModuleExports> | NodePath<t.DeclareOpaqueType> | NodePath<t.DeclareTypeAlias> | NodePath<t.DeclareVariable> | NodePath<t.DoWhileStatement> | NodePath<t.EmptyStatement> | NodePath<t.EnumDeclaration> | NodePath<t.ExportAllDeclaration> | NodePath<t.ExportDefaultDeclaration> | NodePath<t.ExportNamedDeclaration> | NodePath<t.ExpressionStatement> | NodePath<t.ForInStatement> | NodePath<t.ForOfStatement> | NodePath<t.ForStatement> | NodePath<t.FunctionDeclaration> | NodePath<t.IfStatement> | NodePath<t.ImportDeclaration> | NodePath<t.InterfaceDeclaration> | NodePath<t.LabeledStatement> | NodePath<t.OpaqueType> | NodePath<t.ReturnStatement> | NodePath<t.SwitchStatement> | NodePath<t.TSDeclareFunction> | NodePath<t.TSEnumDeclaration> | NodePath<t.TSExportAssignment> | NodePath<t.TSImportEqualsDeclaration> | NodePath<t.TSInterfaceDeclaration> | NodePath<t.TSModuleDeclaration> | NodePath<t.TSNamespaceExportDeclaration> | NodePath<t.TSTypeAliasDeclaration> | NodePath<t.ThrowStatement> | NodePath<t.TryStatement> | NodePath<t.TypeAlias> | NodePath<t.VariableDeclaration> | NodePath<t.WhileStatement> | NodePath<t.WithStatement>)[] | (NodePath<t.Identifier> | NodePath<t.ArrayExpression> | NodePath<t.ArrowFunctionExpression> | NodePath<t.AssignmentExpression> | NodePath<t.AwaitExpression> | NodePath<t.BigIntLiteral> | NodePath<t.BinaryExpression> | NodePath<t.BindExpression> | NodePath<t.BooleanLiteral> | NodePath<t.CallExpression> | NodePath<t.ClassExpression> | NodePath<t.ConditionalExpression> | NodePath<t.DoExpression> | NodePath<t.FunctionExpression> | NodePath<t.Import> | NodePath<t.ImportExpression> | NodePath<t.JSXElement> | NodePath<t.JSXFragment> | NodePath<t.LogicalExpression> | NodePath<t.MemberExpression> | NodePath<t.MetaProperty> | NodePath<t.ModuleExpression> | NodePath<t.NewExpression> | NodePath<t.NullLiteral> | NodePath<t.NumericLiteral> | NodePath<t.ObjectExpression> | NodePath<t.OptionalCallExpression> | NodePath<t.OptionalMemberExpression> | NodePath<t.ParenthesizedExpression> | NodePath<t.PipelineBareFunction> | NodePath<t.PipelinePrimaryTopicReference> | NodePath<t.PipelineTopicExpression> | NodePath<t.RecordExpression> | NodePath<t.RegExpLiteral> | NodePath<t.SequenceExpression> | NodePath<t.StringLiteral> | NodePath<t.TSAnyKeyword> | NodePath<t.TSArrayType> | NodePath<t.TSAsExpression> | NodePath<t.TSBigIntKeyword> | NodePath<t.TSBooleanKeyword> | NodePath<t.TSClassImplements> | NodePath<t.TSConditionalType> | NodePath<t.TSConstructorType> | NodePath<t.TSFunctionType> | NodePath<t.TSImportType> | NodePath<t.TSIndexedAccessType> | NodePath<t.TSInferType> | NodePath<t.TSInstantiationExpression> | NodePath<t.TSInterfaceHeritage> | NodePath<t.TSIntersectionType> | NodePath<t.TSIntrinsicKeyword> | NodePath<t.TSLiteralType> | NodePath<t.TSMappedType> | NodePath<t.TSNeverKeyword> | NodePath<t.TSNonNullExpression> | NodePath<t.TSNullKeyword> | NodePath<t.TSNumberKeyword> | NodePath<t.TSObjectKeyword> | NodePath<t.TSOptionalType> | NodePath<t.TSParenthesizedType> | NodePath<t.TSRestType> | NodePath<t.TSSatisfiesExpression> | NodePath<t.TSStringKeyword> | NodePath<t.TSSymbolKeyword> | NodePath<t.TSTemplateLiteralType> | NodePath<t.TSThisType> | NodePath<t.TSTupleType> | NodePath<t.TSTypeAssertion> | NodePath<t.TSTypeLiteral> | NodePath<t.TSTypeOperator> | NodePath<t.TSTypePredicate> | NodePath<t.TSTypeQuery> | NodePath<t.TSTypeReference> | NodePath<t.TSUndefinedKeyword> | NodePath<t.TSUnionType> | NodePath<t.TSUnknownKeyword> | NodePath<t.TSVoidKeyword> | NodePath<t.TaggedTemplateExpression> | NodePath<t.TemplateLiteral> | NodePath<t.ThisExpression> | NodePath<t.TopicReference> | NodePath<t.TupleExpression> | NodePath<t.TypeCastExpression> | NodePath<t.UnaryExpression> | NodePath<t.UpdateExpression> | NodePath<t.YieldExpression>)[];
992
- declare function replaceInline(this: NodePath_Final, nodes: t.Node | Array<t.Node>): NodePath_Final[];
988
+ declare function replaceInline(this: NodePath_Final, nodes: t.Node | Array<t.Node>): (NodePath<t.Identifier> | NodePath<t.AnyTypeAnnotation> | NodePath<t.ArgumentPlaceholder> | NodePath<t.ArrayExpression> | NodePath<t.ArrayPattern> | NodePath<t.ArrayTypeAnnotation> | NodePath<t.ArrowFunctionExpression> | NodePath<t.AssignmentExpression> | NodePath<t.AssignmentPattern> | NodePath<t.AwaitExpression> | NodePath<t.BigIntLiteral> | NodePath<t.BinaryExpression> | NodePath<t.BindExpression> | NodePath<t.BlockStatement> | NodePath<t.BooleanLiteral> | NodePath<t.BooleanLiteralTypeAnnotation> | NodePath<t.BooleanTypeAnnotation> | NodePath<t.BreakStatement> | NodePath<t.CallExpression> | NodePath<t.CatchClause> | NodePath<t.ClassAccessorProperty> | NodePath<t.ClassBody> | NodePath<t.ClassDeclaration> | NodePath<t.ClassExpression> | NodePath<t.ClassImplements> | NodePath<t.ClassMethod> | NodePath<t.ClassPrivateMethod> | NodePath<t.ClassPrivateProperty> | NodePath<t.ClassProperty> | NodePath<t.ConditionalExpression> | NodePath<t.ContinueStatement> | NodePath<t.DebuggerStatement> | NodePath<t.DeclareClass> | NodePath<t.DeclareExportAllDeclaration> | NodePath<t.DeclareExportDeclaration> | NodePath<t.DeclareFunction> | NodePath<t.DeclareInterface> | NodePath<t.DeclareModule> | NodePath<t.DeclareModuleExports> | NodePath<t.DeclareOpaqueType> | NodePath<t.DeclareTypeAlias> | NodePath<t.DeclareVariable> | NodePath<t.DeclaredPredicate> | NodePath<t.Decorator> | NodePath<t.Directive> | NodePath<t.DirectiveLiteral> | NodePath<t.DoExpression> | NodePath<t.DoWhileStatement> | NodePath<t.EmptyStatement> | NodePath<t.EmptyTypeAnnotation> | NodePath<t.EnumBooleanBody> | NodePath<t.EnumBooleanMember> | NodePath<t.EnumDeclaration> | NodePath<t.EnumDefaultedMember> | NodePath<t.EnumNumberBody> | NodePath<t.EnumNumberMember> | NodePath<t.EnumStringBody> | NodePath<t.EnumStringMember> | NodePath<t.EnumSymbolBody> | NodePath<t.ExistsTypeAnnotation> | NodePath<t.ExportAllDeclaration> | NodePath<t.ExportDefaultDeclaration> | NodePath<t.ExportDefaultSpecifier> | NodePath<t.ExportNamedDeclaration> | NodePath<t.ExportNamespaceSpecifier> | NodePath<t.ExportSpecifier> | NodePath<t.ExpressionStatement> | NodePath<t.File> | NodePath<t.ForInStatement> | NodePath<t.ForOfStatement> | NodePath<t.ForStatement> | NodePath<t.FunctionDeclaration> | NodePath<t.FunctionExpression> | NodePath<t.FunctionTypeAnnotation> | NodePath<t.FunctionTypeParam> | NodePath<t.GenericTypeAnnotation> | NodePath<t.IfStatement> | NodePath<t.Import> | NodePath<t.ImportAttribute> | NodePath<t.ImportDeclaration> | NodePath<t.ImportDefaultSpecifier> | NodePath<t.ImportExpression> | NodePath<t.ImportNamespaceSpecifier> | NodePath<t.ImportSpecifier> | NodePath<t.IndexedAccessType> | NodePath<t.InferredPredicate> | NodePath<t.InterfaceDeclaration> | NodePath<t.InterfaceExtends> | NodePath<t.InterfaceTypeAnnotation> | NodePath<t.InterpreterDirective> | NodePath<t.IntersectionTypeAnnotation> | NodePath<t.JSXAttribute> | NodePath<t.JSXClosingElement> | NodePath<t.JSXClosingFragment> | NodePath<t.JSXElement> | NodePath<t.JSXEmptyExpression> | NodePath<t.JSXExpressionContainer> | NodePath<t.JSXFragment> | NodePath<t.JSXIdentifier> | NodePath<t.JSXMemberExpression> | NodePath<t.JSXNamespacedName> | NodePath<t.JSXOpeningElement> | NodePath<t.JSXOpeningFragment> | NodePath<t.JSXSpreadAttribute> | NodePath<t.JSXSpreadChild> | NodePath<t.JSXText> | NodePath<t.LabeledStatement> | NodePath<t.LogicalExpression> | NodePath<t.MemberExpression> | NodePath<t.MetaProperty> | NodePath<t.MixedTypeAnnotation> | NodePath<t.ModuleExpression> | NodePath<t.NewExpression> | NodePath<t.NullLiteral> | NodePath<t.NullLiteralTypeAnnotation> | NodePath<t.NullableTypeAnnotation> | NodePath<t.NumberLiteral> | NodePath<t.NumberLiteralTypeAnnotation> | NodePath<t.NumberTypeAnnotation> | NodePath<t.NumericLiteral> | NodePath<t.ObjectExpression> | NodePath<t.ObjectMethod> | NodePath<t.ObjectPattern> | NodePath<t.ObjectProperty> | NodePath<t.ObjectTypeAnnotation> | NodePath<t.ObjectTypeCallProperty> | NodePath<t.ObjectTypeIndexer> | NodePath<t.ObjectTypeInternalSlot> | NodePath<t.ObjectTypeProperty> | NodePath<t.ObjectTypeSpreadProperty> | NodePath<t.OpaqueType> | NodePath<t.OptionalCallExpression> | NodePath<t.OptionalIndexedAccessType> | NodePath<t.OptionalMemberExpression> | NodePath<t.ParenthesizedExpression> | NodePath<t.PipelineBareFunction> | NodePath<t.PipelinePrimaryTopicReference> | NodePath<t.PipelineTopicExpression> | NodePath<t.Placeholder> | NodePath<t.PrivateName> | NodePath<t.Program> | NodePath<t.QualifiedTypeIdentifier> | NodePath<t.RecordExpression> | NodePath<t.RegExpLiteral> | NodePath<t.RegexLiteral> | NodePath<t.RestElement> | NodePath<t.RestProperty> | NodePath<t.ReturnStatement> | NodePath<t.SequenceExpression> | NodePath<t.SpreadElement> | NodePath<t.SpreadProperty> | NodePath<t.StaticBlock> | NodePath<t.StringLiteral> | NodePath<t.StringLiteralTypeAnnotation> | NodePath<t.StringTypeAnnotation> | NodePath<t.Super> | NodePath<t.SwitchCase> | NodePath<t.SwitchStatement> | NodePath<t.SymbolTypeAnnotation> | NodePath<t.TSAnyKeyword> | NodePath<t.TSArrayType> | NodePath<t.TSAsExpression> | NodePath<t.TSBigIntKeyword> | NodePath<t.TSBooleanKeyword> | NodePath<t.TSCallSignatureDeclaration> | NodePath<t.TSClassImplements> | NodePath<t.TSConditionalType> | NodePath<t.TSConstructSignatureDeclaration> | NodePath<t.TSConstructorType> | NodePath<t.TSDeclareFunction> | NodePath<t.TSDeclareMethod> | NodePath<t.TSEnumBody> | NodePath<t.TSEnumDeclaration> | NodePath<t.TSEnumMember> | NodePath<t.TSExportAssignment> | NodePath<t.TSExternalModuleReference> | NodePath<t.TSFunctionType> | NodePath<t.TSImportEqualsDeclaration> | NodePath<t.TSImportType> | NodePath<t.TSIndexSignature> | NodePath<t.TSIndexedAccessType> | NodePath<t.TSInferType> | NodePath<t.TSInstantiationExpression> | NodePath<t.TSInterfaceBody> | NodePath<t.TSInterfaceDeclaration> | NodePath<t.TSInterfaceHeritage> | NodePath<t.TSIntersectionType> | NodePath<t.TSIntrinsicKeyword> | NodePath<t.TSLiteralType> | NodePath<t.TSMappedType> | NodePath<t.TSMethodSignature> | NodePath<t.TSModuleBlock> | NodePath<t.TSModuleDeclaration> | NodePath<t.TSNamedTupleMember> | NodePath<t.TSNamespaceExportDeclaration> | NodePath<t.TSNeverKeyword> | NodePath<t.TSNonNullExpression> | NodePath<t.TSNullKeyword> | NodePath<t.TSNumberKeyword> | NodePath<t.TSObjectKeyword> | NodePath<t.TSOptionalType> | NodePath<t.TSParameterProperty> | NodePath<t.TSParenthesizedType> | NodePath<t.TSPropertySignature> | NodePath<t.TSQualifiedName> | NodePath<t.TSRestType> | NodePath<t.TSSatisfiesExpression> | NodePath<t.TSStringKeyword> | NodePath<t.TSSymbolKeyword> | NodePath<t.TSTemplateLiteralType> | NodePath<t.TSThisType> | NodePath<t.TSTupleType> | NodePath<t.TSTypeAliasDeclaration> | NodePath<t.TSTypeAnnotation> | NodePath<t.TSTypeAssertion> | NodePath<t.TSTypeLiteral> | NodePath<t.TSTypeOperator> | NodePath<t.TSTypeParameter> | NodePath<t.TSTypeParameterDeclaration> | NodePath<t.TSTypeParameterInstantiation> | NodePath<t.TSTypePredicate> | NodePath<t.TSTypeQuery> | NodePath<t.TSTypeReference> | NodePath<t.TSUndefinedKeyword> | NodePath<t.TSUnionType> | NodePath<t.TSUnknownKeyword> | NodePath<t.TSVoidKeyword> | NodePath<t.TaggedTemplateExpression> | NodePath<t.TemplateElement> | NodePath<t.TemplateLiteral> | NodePath<t.ThisExpression> | NodePath<t.ThisTypeAnnotation> | NodePath<t.ThrowStatement> | NodePath<t.TopicReference> | NodePath<t.TryStatement> | NodePath<t.TupleExpression> | NodePath<t.TupleTypeAnnotation> | NodePath<t.TypeAlias> | NodePath<t.TypeAnnotation> | NodePath<t.TypeCastExpression> | NodePath<t.TypeParameter> | NodePath<t.TypeParameterDeclaration> | NodePath<t.TypeParameterInstantiation> | NodePath<t.TypeofTypeAnnotation> | NodePath<t.UnaryExpression> | NodePath<t.UnionTypeAnnotation> | NodePath<t.UpdateExpression> | NodePath<t.V8IntrinsicIdentifier> | NodePath<t.VariableDeclaration> | NodePath<t.VariableDeclarator> | NodePath<t.Variance> | NodePath<t.VoidPattern> | NodePath<t.VoidTypeAnnotation> | NodePath<t.WhileStatement> | NodePath<t.WithStatement> | NodePath<t.YieldExpression>)[];
993
989
 
994
990
  /**
995
991
  * Walk the input `node` and statically evaluate if it's truthy.
@@ -1135,14 +1131,17 @@ declare function remove(this: NodePath_Final): void;
1135
1131
  /**
1136
1132
  * Insert the provided nodes before the current one.
1137
1133
  */
1138
- declare function insertBefore(this: NodePath_Final, nodes_: t.Node | t.Node[]): NodePath_Final[];
1134
+ declare function insertBefore<Nodes extends NodeOrNodeList<t.Node>>(this: NodePath_Final, nodes_: Nodes): NodePaths<Nodes>;
1139
1135
  /**
1140
1136
  * Insert the provided nodes after the current one. When inserting nodes after an
1141
1137
  * expression, ensure that the completion record is correct by pushing the current node.
1142
1138
  */
1143
- declare function insertAfter(this: NodePath_Final, nodes_: t.Node | t.Node[]): NodePath_Final[];
1144
- declare function unshiftContainer<N extends t.Node, K extends keyof N & string>(this: NodePath_Final<N>, listKey: K, nodes: N[K] extends (infer E)[] ? E | E[] : never): (NodePath<t.Identifier> | NodePath<t.AnyTypeAnnotation> | NodePath<t.ArgumentPlaceholder> | NodePath<t.ArrayExpression> | NodePath<t.ArrayPattern> | NodePath<t.ArrayTypeAnnotation> | NodePath<t.ArrowFunctionExpression> | NodePath<t.AssignmentExpression> | NodePath<t.AssignmentPattern> | NodePath<t.AwaitExpression> | NodePath<t.BigIntLiteral> | NodePath<t.BinaryExpression> | NodePath<t.BindExpression> | NodePath<t.BlockStatement> | NodePath<t.BooleanLiteral> | NodePath<t.BooleanLiteralTypeAnnotation> | NodePath<t.BooleanTypeAnnotation> | NodePath<t.BreakStatement> | NodePath<t.CallExpression> | NodePath<t.CatchClause> | NodePath<t.ClassAccessorProperty> | NodePath<t.ClassBody> | NodePath<t.ClassDeclaration> | NodePath<t.ClassExpression> | NodePath<t.ClassImplements> | NodePath<t.ClassMethod> | NodePath<t.ClassPrivateMethod> | NodePath<t.ClassPrivateProperty> | NodePath<t.ClassProperty> | NodePath<t.ConditionalExpression> | NodePath<t.ContinueStatement> | NodePath<t.DebuggerStatement> | NodePath<t.DeclareClass> | NodePath<t.DeclareExportAllDeclaration> | NodePath<t.DeclareExportDeclaration> | NodePath<t.DeclareFunction> | NodePath<t.DeclareInterface> | NodePath<t.DeclareModule> | NodePath<t.DeclareModuleExports> | NodePath<t.DeclareOpaqueType> | NodePath<t.DeclareTypeAlias> | NodePath<t.DeclareVariable> | NodePath<t.DeclaredPredicate> | NodePath<t.Decorator> | NodePath<t.Directive> | NodePath<t.DirectiveLiteral> | NodePath<t.DoExpression> | NodePath<t.DoWhileStatement> | NodePath<t.EmptyStatement> | NodePath<t.EmptyTypeAnnotation> | NodePath<t.EnumBooleanBody> | NodePath<t.EnumBooleanMember> | NodePath<t.EnumDeclaration> | NodePath<t.EnumDefaultedMember> | NodePath<t.EnumNumberBody> | NodePath<t.EnumNumberMember> | NodePath<t.EnumStringBody> | NodePath<t.EnumStringMember> | NodePath<t.EnumSymbolBody> | NodePath<t.ExistsTypeAnnotation> | NodePath<t.ExportAllDeclaration> | NodePath<t.ExportDefaultDeclaration> | NodePath<t.ExportDefaultSpecifier> | NodePath<t.ExportNamedDeclaration> | NodePath<t.ExportNamespaceSpecifier> | NodePath<t.ExportSpecifier> | NodePath<t.ExpressionStatement> | NodePath<t.File> | NodePath<t.ForInStatement> | NodePath<t.ForOfStatement> | NodePath<t.ForStatement> | NodePath<t.FunctionDeclaration> | NodePath<t.FunctionExpression> | NodePath<t.FunctionTypeAnnotation> | NodePath<t.FunctionTypeParam> | NodePath<t.GenericTypeAnnotation> | NodePath<t.IfStatement> | NodePath<t.Import> | NodePath<t.ImportAttribute> | NodePath<t.ImportDeclaration> | NodePath<t.ImportDefaultSpecifier> | NodePath<t.ImportExpression> | NodePath<t.ImportNamespaceSpecifier> | NodePath<t.ImportSpecifier> | NodePath<t.IndexedAccessType> | NodePath<t.InferredPredicate> | NodePath<t.InterfaceDeclaration> | NodePath<t.InterfaceExtends> | NodePath<t.InterfaceTypeAnnotation> | NodePath<t.InterpreterDirective> | NodePath<t.IntersectionTypeAnnotation> | NodePath<t.JSXAttribute> | NodePath<t.JSXClosingElement> | NodePath<t.JSXClosingFragment> | NodePath<t.JSXElement> | NodePath<t.JSXEmptyExpression> | NodePath<t.JSXExpressionContainer> | NodePath<t.JSXFragment> | NodePath<t.JSXIdentifier> | NodePath<t.JSXMemberExpression> | NodePath<t.JSXNamespacedName> | NodePath<t.JSXOpeningElement> | NodePath<t.JSXOpeningFragment> | NodePath<t.JSXSpreadAttribute> | NodePath<t.JSXSpreadChild> | NodePath<t.JSXText> | NodePath<t.LabeledStatement> | NodePath<t.LogicalExpression> | NodePath<t.MemberExpression> | NodePath<t.MetaProperty> | NodePath<t.MixedTypeAnnotation> | NodePath<t.ModuleExpression> | NodePath<t.NewExpression> | NodePath<t.NullLiteral> | NodePath<t.NullLiteralTypeAnnotation> | NodePath<t.NullableTypeAnnotation> | NodePath<t.NumberLiteral> | NodePath<t.NumberLiteralTypeAnnotation> | NodePath<t.NumberTypeAnnotation> | NodePath<t.NumericLiteral> | NodePath<t.ObjectExpression> | NodePath<t.ObjectMethod> | NodePath<t.ObjectPattern> | NodePath<t.ObjectProperty> | NodePath<t.ObjectTypeAnnotation> | NodePath<t.ObjectTypeCallProperty> | NodePath<t.ObjectTypeIndexer> | NodePath<t.ObjectTypeInternalSlot> | NodePath<t.ObjectTypeProperty> | NodePath<t.ObjectTypeSpreadProperty> | NodePath<t.OpaqueType> | NodePath<t.OptionalCallExpression> | NodePath<t.OptionalIndexedAccessType> | NodePath<t.OptionalMemberExpression> | NodePath<t.ParenthesizedExpression> | NodePath<t.PipelineBareFunction> | NodePath<t.PipelinePrimaryTopicReference> | NodePath<t.PipelineTopicExpression> | NodePath<t.Placeholder> | NodePath<t.PrivateName> | NodePath<t.Program> | NodePath<t.QualifiedTypeIdentifier> | NodePath<t.RecordExpression> | NodePath<t.RegExpLiteral> | NodePath<t.RegexLiteral> | NodePath<t.RestElement> | NodePath<t.RestProperty> | NodePath<t.ReturnStatement> | NodePath<t.SequenceExpression> | NodePath<t.SpreadElement> | NodePath<t.SpreadProperty> | NodePath<t.StaticBlock> | NodePath<t.StringLiteral> | NodePath<t.StringLiteralTypeAnnotation> | NodePath<t.StringTypeAnnotation> | NodePath<t.Super> | NodePath<t.SwitchCase> | NodePath<t.SwitchStatement> | NodePath<t.SymbolTypeAnnotation> | NodePath<t.TSAnyKeyword> | NodePath<t.TSArrayType> | NodePath<t.TSAsExpression> | NodePath<t.TSBigIntKeyword> | NodePath<t.TSBooleanKeyword> | NodePath<t.TSCallSignatureDeclaration> | NodePath<t.TSClassImplements> | NodePath<t.TSConditionalType> | NodePath<t.TSConstructSignatureDeclaration> | NodePath<t.TSConstructorType> | NodePath<t.TSDeclareFunction> | NodePath<t.TSDeclareMethod> | NodePath<t.TSEnumBody> | NodePath<t.TSEnumDeclaration> | NodePath<t.TSEnumMember> | NodePath<t.TSExportAssignment> | NodePath<t.TSExternalModuleReference> | NodePath<t.TSFunctionType> | NodePath<t.TSImportEqualsDeclaration> | NodePath<t.TSImportType> | NodePath<t.TSIndexSignature> | NodePath<t.TSIndexedAccessType> | NodePath<t.TSInferType> | NodePath<t.TSInstantiationExpression> | NodePath<t.TSInterfaceBody> | NodePath<t.TSInterfaceDeclaration> | NodePath<t.TSInterfaceHeritage> | NodePath<t.TSIntersectionType> | NodePath<t.TSIntrinsicKeyword> | NodePath<t.TSLiteralType> | NodePath<t.TSMappedType> | NodePath<t.TSMethodSignature> | NodePath<t.TSModuleBlock> | NodePath<t.TSModuleDeclaration> | NodePath<t.TSNamedTupleMember> | NodePath<t.TSNamespaceExportDeclaration> | NodePath<t.TSNeverKeyword> | NodePath<t.TSNonNullExpression> | NodePath<t.TSNullKeyword> | NodePath<t.TSNumberKeyword> | NodePath<t.TSObjectKeyword> | NodePath<t.TSOptionalType> | NodePath<t.TSParameterProperty> | NodePath<t.TSParenthesizedType> | NodePath<t.TSPropertySignature> | NodePath<t.TSQualifiedName> | NodePath<t.TSRestType> | NodePath<t.TSSatisfiesExpression> | NodePath<t.TSStringKeyword> | NodePath<t.TSSymbolKeyword> | NodePath<t.TSTemplateLiteralType> | NodePath<t.TSThisType> | NodePath<t.TSTupleType> | NodePath<t.TSTypeAliasDeclaration> | NodePath<t.TSTypeAnnotation> | NodePath<t.TSTypeAssertion> | NodePath<t.TSTypeLiteral> | NodePath<t.TSTypeOperator> | NodePath<t.TSTypeParameter> | NodePath<t.TSTypeParameterDeclaration> | NodePath<t.TSTypeParameterInstantiation> | NodePath<t.TSTypePredicate> | NodePath<t.TSTypeQuery> | NodePath<t.TSTypeReference> | NodePath<t.TSUndefinedKeyword> | NodePath<t.TSUnionType> | NodePath<t.TSUnknownKeyword> | NodePath<t.TSVoidKeyword> | NodePath<t.TaggedTemplateExpression> | NodePath<t.TemplateElement> | NodePath<t.TemplateLiteral> | NodePath<t.ThisExpression> | NodePath<t.ThisTypeAnnotation> | NodePath<t.ThrowStatement> | NodePath<t.TopicReference> | NodePath<t.TryStatement> | NodePath<t.TupleExpression> | NodePath<t.TupleTypeAnnotation> | NodePath<t.TypeAlias> | NodePath<t.TypeAnnotation> | NodePath<t.TypeCastExpression> | NodePath<t.TypeParameter> | NodePath<t.TypeParameterDeclaration> | NodePath<t.TypeParameterInstantiation> | NodePath<t.TypeofTypeAnnotation> | NodePath<t.UnaryExpression> | NodePath<t.UnionTypeAnnotation> | NodePath<t.UpdateExpression> | NodePath<t.V8IntrinsicIdentifier> | NodePath<t.VariableDeclaration> | NodePath<t.VariableDeclarator> | NodePath<t.Variance> | NodePath<t.VoidTypeAnnotation> | NodePath<t.WhileStatement> | NodePath<t.WithStatement> | NodePath<t.YieldExpression>)[];
1145
- declare function pushContainer<P extends NodePath_Final, K extends string & keyof P["node"]>(this: P, listKey: K, nodes: P["node"][K] extends (infer E)[] ? E | E[] : never): NodePath_Final[];
1139
+ declare function insertAfter<Nodes extends NodeOrNodeList<t.Node>>(this: NodePath_Final, nodes_: Nodes): NodePaths<Nodes>;
1140
+ type NodeKeyOfArrays<N extends t.Node> = {
1141
+ [P in string & keyof N]-?: N[P] extends Array<t.Node | null> ? P : never;
1142
+ }[string & keyof N];
1143
+ declare function unshiftContainer<N extends t.Node, K extends NodeKeyOfArrays<N>, Nodes extends NodeOrNodeList<NodeListType<N, K>>>(this: NodePath_Final<N>, listKey: K, nodes: Nodes): NodePaths<Nodes>;
1144
+ declare function pushContainer<N extends t.Node, K extends NodeKeyOfArrays<N>, Nodes extends NodeOrNodeList<NodeListType<N, K>>>(this: NodePath_Final<N>, listKey: K, nodes: Nodes): NodePaths<Nodes>;
1146
1145
 
1147
1146
  declare function getOpposite(this: NodePath_Final): NodePath_Final | null;
1148
1147
  /**
@@ -1166,8 +1165,8 @@ type MaybeToIndex<T extends string> = T extends `${bigint}` ? number : T;
1166
1165
  type Pattern<Obj extends string, Prop extends string> = `${Obj}.${Prop}`;
1167
1166
  type Split<P extends string> = P extends Pattern<infer O, infer U> ? [MaybeToIndex<O>, ...Split<U>] : [MaybeToIndex<P>];
1168
1167
  type Trav<Node extends t.Node | t.Node[], Path extends unknown[]> = Path extends [infer K, ...infer R] ? K extends keyof Node ? Node[K] extends t.Node | t.Node[] ? R extends [] ? Node[K] : Trav<Node[K], R> : never : never : never;
1169
- type ToNodePath<T> = T extends Array<t.Node | null | undefined> ? Array<NodePath_Final<T[number]>> : T extends t.Node | null | undefined ? NodePath_Final<T> : never;
1170
- declare function get<T extends NodePath_Final, K extends keyof T["node"]>(this: T, key: K, context?: boolean | TraversalContext): T extends any ? T["node"][K] extends Array<t.Node | null | undefined> ? Array<NodePath_Final<T["node"][K][number]>> : T["node"][K] extends t.Node | null | undefined ? NodePath_Final<T["node"][K]> : never : never;
1168
+ type ToNodePath<T> = T extends Array<(infer U extends t.Node) | null | undefined> ? Array<NodePath_Final<U> | null | undefined> : T extends (infer U extends t.Node) | null | undefined ? NodePath_Final<U> | null | undefined : never;
1169
+ declare function get<T extends NodePath_Final, K extends keyof T["node"]>(this: T, key: K, context?: boolean | TraversalContext): T extends any ? T["node"][K] extends Array<(infer U extends t.Node) | null | undefined> ? Array<NodePath_Final<U> | null | undefined> : T["node"][K] extends (infer U extends t.Node) | null | undefined ? NodePath_Final<U> | null | undefined : never : never;
1171
1170
  declare function get<T extends NodePath_Final, K extends string>(this: T, key: K, context?: boolean | TraversalContext): T extends any ? ToNodePath<Trav<T["node"], Split<K>>> : never;
1172
1171
  declare function get(this: NodePath_Final, key: string, context?: true | TraversalContext): NodePath_Final | NodePath_Final[];
1173
1172
 
@@ -1472,6 +1471,9 @@ interface NodePathAssertions {
1472
1471
  assertFunctionExpression(
1473
1472
  opts?: Opts$2<t.FunctionExpression>,
1474
1473
  ): asserts this is NodePath_Final<t.FunctionExpression>;
1474
+ assertFunctionParameter(
1475
+ opts?: Opts$2<t.FunctionParameter>,
1476
+ ): asserts this is NodePath_Final<t.FunctionParameter>;
1475
1477
  assertFunctionParent(
1476
1478
  opts?: Opts$2<t.FunctionParent>,
1477
1479
  ): asserts this is NodePath_Final<t.FunctionParent>;
@@ -2061,6 +2063,9 @@ interface NodePathAssertions {
2061
2063
  opts?: Opts$2<t.VariableDeclarator>,
2062
2064
  ): asserts this is NodePath_Final<t.VariableDeclarator>;
2063
2065
  assertVariance(opts?: Opts$2<t.Variance>): asserts this is NodePath_Final<t.Variance>;
2066
+ assertVoidPattern(
2067
+ opts?: Opts$2<t.VoidPattern>,
2068
+ ): asserts this is NodePath_Final<t.VoidPattern>;
2064
2069
  assertVoidTypeAnnotation(
2065
2070
  opts?: Opts$2<t.VoidTypeAnnotation>,
2066
2071
  ): asserts this is NodePath_Final<t.VoidTypeAnnotation>;
@@ -2475,6 +2480,10 @@ interface BaseNodePathValidators {
2475
2480
  this: NodePath_Final,
2476
2481
  opts?: Opts<t.FunctionExpression>,
2477
2482
  ): this is NodePath_Final<t.FunctionExpression>;
2483
+ isFunctionParameter(
2484
+ this: NodePath_Final,
2485
+ opts?: Opts<t.FunctionParameter>,
2486
+ ): this is NodePath_Final<t.FunctionParameter>;
2478
2487
  isFunctionParent(
2479
2488
  this: NodePath_Final,
2480
2489
  opts?: Opts<t.FunctionParent>,
@@ -3282,6 +3291,10 @@ interface BaseNodePathValidators {
3282
3291
  this: NodePath_Final,
3283
3292
  opts?: Opts<t.Variance>,
3284
3293
  ): this is NodePath_Final<t.Variance>;
3294
+ isVoidPattern(
3295
+ this: NodePath_Final,
3296
+ opts?: Opts<t.VoidPattern>,
3297
+ ): this is NodePath_Final<t.VoidPattern>;
3285
3298
  isVoidTypeAnnotation(
3286
3299
  this: NodePath_Final,
3287
3300
  opts?: Opts<t.VoidTypeAnnotation>,
@@ -3305,6 +3318,12 @@ interface NodePathValidators
3305
3318
  extends Omit<BaseNodePathValidators, keyof VirtualTypeNodePathValidators>,
3306
3319
  VirtualTypeNodePathValidators {}
3307
3320
 
3321
+ type NodePaths<T extends t.Node | t.Node[]> = T extends t.Node[] ? {
3322
+ [K in keyof T]: NodePath_Final<Extract<T[K], t.Node>>;
3323
+ } : T extends t.Node ? [NodePath_Final<T>] : never;
3324
+ type NodeListType<N, K extends keyof N> = N[K] extends Array<infer P extends t.Node> ? P : never;
3325
+ type NodeOrNodeList<T extends t.Node> = T | NodeList<T>;
3326
+ type NodeList<T extends t.Node> = T[] | [T, ...T[]];
3308
3327
  declare const methods: {
3309
3328
  findParent: typeof findParent;
3310
3329
  find: typeof find;
@@ -3397,8 +3416,8 @@ type NodePathMixins = Omit<typeof methods, keyof NodePathOverwrites>;
3397
3416
  interface NodePath<T extends t.Node> extends InstanceType<typeof NodePath_Final>, NodePathAssertions, NodePathValidators, NodePathMixins, NodePathOverwrites {
3398
3417
  type: T["type"] | null;
3399
3418
  node: T;
3400
- parent: t.ParentMaps[T["type"]];
3401
- parentPath: t.ParentMaps[T["type"]] extends null ? null : NodePath_Final<t.ParentMaps[T["type"]]> | null;
3419
+ parent: NonNullable<t.ParentMaps[T["type"]]>;
3420
+ parentPath: NodePath_Final<NonNullable<t.ParentMaps[T["type"]]>>;
3402
3421
  }
3403
3422
  declare const NodePath_Final: {
3404
3423
  new (hub: HubInterface, parent: t.Node | null): {
@@ -3411,11 +3430,14 @@ declare const NodePath_Final: {
3411
3430
  state: any;
3412
3431
  opts: ExplodedTraverseOptions | null;
3413
3432
  _traverseFlags: number;
3414
- removed: boolean;
3415
- shouldStop: boolean;
3416
- shouldSkip: boolean;
3433
+ get removed(): boolean;
3434
+ set removed(arg: boolean);
3435
+ get shouldStop(): boolean;
3436
+ set shouldStop(arg: boolean);
3437
+ get shouldSkip(): boolean;
3438
+ set shouldSkip(arg: boolean);
3417
3439
  skipKeys: Record<string, boolean> | null;
3418
- parentPath: NodePath_Final | null;
3440
+ parentPath: NodePath_Final;
3419
3441
  container: t.Node | Array<t.Node> | null;
3420
3442
  listKey: string | null;
3421
3443
  key: string | number | null;
@@ -3423,7 +3445,7 @@ declare const NodePath_Final: {
3423
3445
  type: t.Node["type"] | null;
3424
3446
  _store: Map<t.Node, NodePath_Final> | null;
3425
3447
  getScope(this: NodePath_Final, scope: Scope): Scope;
3426
- setData(key: string | symbol, val: any): any;
3448
+ setData<T>(key: string | symbol, val: T): T;
3427
3449
  getData(key: string | symbol, def?: any): any;
3428
3450
  hasNode(): boolean;
3429
3451
  buildCodeFrameError(msg: string, Error?: new () => Error): Error;
@@ -3433,8 +3455,9 @@ declare const NodePath_Final: {
3433
3455
  getPathLocation(this: NodePath_Final): string;
3434
3456
  debug(this: NodePath_Final, message: string): void;
3435
3457
  toString(): string;
3436
- inList: boolean;
3437
- readonly parentKey: string;
3458
+ get inList(): boolean;
3459
+ set inList(inList: boolean);
3460
+ get parentKey(): string;
3438
3461
  };
3439
3462
  get({ hub, parentPath, parent, container, listKey, key, }: {
3440
3463
  hub?: HubInterface;
@@ -3453,7 +3476,7 @@ declare let scope: WeakMap<Node, Scope>;
3453
3476
  declare function clear(): void;
3454
3477
  declare function clearPath(): void;
3455
3478
  declare function clearScope(): void;
3456
- declare function getCachedPaths(path: NodePath_Final): Map<Node, NodePath<t.Identifier> | NodePath<t.AnyTypeAnnotation> | NodePath<t.ArgumentPlaceholder> | NodePath<t.ArrayExpression> | NodePath<t.ArrayPattern> | NodePath<t.ArrayTypeAnnotation> | NodePath<t.ArrowFunctionExpression> | NodePath<t.AssignmentExpression> | NodePath<t.AssignmentPattern> | NodePath<t.AwaitExpression> | NodePath<t.BigIntLiteral> | NodePath<t.BinaryExpression> | NodePath<t.BindExpression> | NodePath<t.BlockStatement> | NodePath<t.BooleanLiteral> | NodePath<t.BooleanLiteralTypeAnnotation> | NodePath<t.BooleanTypeAnnotation> | NodePath<t.BreakStatement> | NodePath<t.CallExpression> | NodePath<t.CatchClause> | NodePath<t.ClassAccessorProperty> | NodePath<t.ClassBody> | NodePath<t.ClassDeclaration> | NodePath<t.ClassExpression> | NodePath<t.ClassImplements> | NodePath<t.ClassMethod> | NodePath<t.ClassPrivateMethod> | NodePath<t.ClassPrivateProperty> | NodePath<t.ClassProperty> | NodePath<t.ConditionalExpression> | NodePath<t.ContinueStatement> | NodePath<t.DebuggerStatement> | NodePath<t.DeclareClass> | NodePath<t.DeclareExportAllDeclaration> | NodePath<t.DeclareExportDeclaration> | NodePath<t.DeclareFunction> | NodePath<t.DeclareInterface> | NodePath<t.DeclareModule> | NodePath<t.DeclareModuleExports> | NodePath<t.DeclareOpaqueType> | NodePath<t.DeclareTypeAlias> | NodePath<t.DeclareVariable> | NodePath<t.DeclaredPredicate> | NodePath<t.Decorator> | NodePath<t.Directive> | NodePath<t.DirectiveLiteral> | NodePath<t.DoExpression> | NodePath<t.DoWhileStatement> | NodePath<t.EmptyStatement> | NodePath<t.EmptyTypeAnnotation> | NodePath<t.EnumBooleanBody> | NodePath<t.EnumBooleanMember> | NodePath<t.EnumDeclaration> | NodePath<t.EnumDefaultedMember> | NodePath<t.EnumNumberBody> | NodePath<t.EnumNumberMember> | NodePath<t.EnumStringBody> | NodePath<t.EnumStringMember> | NodePath<t.EnumSymbolBody> | NodePath<t.ExistsTypeAnnotation> | NodePath<t.ExportAllDeclaration> | NodePath<t.ExportDefaultDeclaration> | NodePath<t.ExportDefaultSpecifier> | NodePath<t.ExportNamedDeclaration> | NodePath<t.ExportNamespaceSpecifier> | NodePath<t.ExportSpecifier> | NodePath<t.ExpressionStatement> | NodePath<t.File> | NodePath<t.ForInStatement> | NodePath<t.ForOfStatement> | NodePath<t.ForStatement> | NodePath<t.FunctionDeclaration> | NodePath<t.FunctionExpression> | NodePath<t.FunctionTypeAnnotation> | NodePath<t.FunctionTypeParam> | NodePath<t.GenericTypeAnnotation> | NodePath<t.IfStatement> | NodePath<t.Import> | NodePath<t.ImportAttribute> | NodePath<t.ImportDeclaration> | NodePath<t.ImportDefaultSpecifier> | NodePath<t.ImportExpression> | NodePath<t.ImportNamespaceSpecifier> | NodePath<t.ImportSpecifier> | NodePath<t.IndexedAccessType> | NodePath<t.InferredPredicate> | NodePath<t.InterfaceDeclaration> | NodePath<t.InterfaceExtends> | NodePath<t.InterfaceTypeAnnotation> | NodePath<t.InterpreterDirective> | NodePath<t.IntersectionTypeAnnotation> | NodePath<t.JSXAttribute> | NodePath<t.JSXClosingElement> | NodePath<t.JSXClosingFragment> | NodePath<t.JSXElement> | NodePath<t.JSXEmptyExpression> | NodePath<t.JSXExpressionContainer> | NodePath<t.JSXFragment> | NodePath<t.JSXIdentifier> | NodePath<t.JSXMemberExpression> | NodePath<t.JSXNamespacedName> | NodePath<t.JSXOpeningElement> | NodePath<t.JSXOpeningFragment> | NodePath<t.JSXSpreadAttribute> | NodePath<t.JSXSpreadChild> | NodePath<t.JSXText> | NodePath<t.LabeledStatement> | NodePath<t.LogicalExpression> | NodePath<t.MemberExpression> | NodePath<t.MetaProperty> | NodePath<t.MixedTypeAnnotation> | NodePath<t.ModuleExpression> | NodePath<t.NewExpression> | NodePath<t.NullLiteral> | NodePath<t.NullLiteralTypeAnnotation> | NodePath<t.NullableTypeAnnotation> | NodePath<t.NumberLiteral> | NodePath<t.NumberLiteralTypeAnnotation> | NodePath<t.NumberTypeAnnotation> | NodePath<t.NumericLiteral> | NodePath<t.ObjectExpression> | NodePath<t.ObjectMethod> | NodePath<t.ObjectPattern> | NodePath<t.ObjectProperty> | NodePath<t.ObjectTypeAnnotation> | NodePath<t.ObjectTypeCallProperty> | NodePath<t.ObjectTypeIndexer> | NodePath<t.ObjectTypeInternalSlot> | NodePath<t.ObjectTypeProperty> | NodePath<t.ObjectTypeSpreadProperty> | NodePath<t.OpaqueType> | NodePath<t.OptionalCallExpression> | NodePath<t.OptionalIndexedAccessType> | NodePath<t.OptionalMemberExpression> | NodePath<t.ParenthesizedExpression> | NodePath<t.PipelineBareFunction> | NodePath<t.PipelinePrimaryTopicReference> | NodePath<t.PipelineTopicExpression> | NodePath<t.Placeholder> | NodePath<t.PrivateName> | NodePath<t.Program> | NodePath<t.QualifiedTypeIdentifier> | NodePath<t.RecordExpression> | NodePath<t.RegExpLiteral> | NodePath<t.RegexLiteral> | NodePath<t.RestElement> | NodePath<t.RestProperty> | NodePath<t.ReturnStatement> | NodePath<t.SequenceExpression> | NodePath<t.SpreadElement> | NodePath<t.SpreadProperty> | NodePath<t.StaticBlock> | NodePath<t.StringLiteral> | NodePath<t.StringLiteralTypeAnnotation> | NodePath<t.StringTypeAnnotation> | NodePath<t.Super> | NodePath<t.SwitchCase> | NodePath<t.SwitchStatement> | NodePath<t.SymbolTypeAnnotation> | NodePath<t.TSAnyKeyword> | NodePath<t.TSArrayType> | NodePath<t.TSAsExpression> | NodePath<t.TSBigIntKeyword> | NodePath<t.TSBooleanKeyword> | NodePath<t.TSCallSignatureDeclaration> | NodePath<t.TSClassImplements> | NodePath<t.TSConditionalType> | NodePath<t.TSConstructSignatureDeclaration> | NodePath<t.TSConstructorType> | NodePath<t.TSDeclareFunction> | NodePath<t.TSDeclareMethod> | NodePath<t.TSEnumBody> | NodePath<t.TSEnumDeclaration> | NodePath<t.TSEnumMember> | NodePath<t.TSExportAssignment> | NodePath<t.TSExternalModuleReference> | NodePath<t.TSFunctionType> | NodePath<t.TSImportEqualsDeclaration> | NodePath<t.TSImportType> | NodePath<t.TSIndexSignature> | NodePath<t.TSIndexedAccessType> | NodePath<t.TSInferType> | NodePath<t.TSInstantiationExpression> | NodePath<t.TSInterfaceBody> | NodePath<t.TSInterfaceDeclaration> | NodePath<t.TSInterfaceHeritage> | NodePath<t.TSIntersectionType> | NodePath<t.TSIntrinsicKeyword> | NodePath<t.TSLiteralType> | NodePath<t.TSMappedType> | NodePath<t.TSMethodSignature> | NodePath<t.TSModuleBlock> | NodePath<t.TSModuleDeclaration> | NodePath<t.TSNamedTupleMember> | NodePath<t.TSNamespaceExportDeclaration> | NodePath<t.TSNeverKeyword> | NodePath<t.TSNonNullExpression> | NodePath<t.TSNullKeyword> | NodePath<t.TSNumberKeyword> | NodePath<t.TSObjectKeyword> | NodePath<t.TSOptionalType> | NodePath<t.TSParameterProperty> | NodePath<t.TSParenthesizedType> | NodePath<t.TSPropertySignature> | NodePath<t.TSQualifiedName> | NodePath<t.TSRestType> | NodePath<t.TSSatisfiesExpression> | NodePath<t.TSStringKeyword> | NodePath<t.TSSymbolKeyword> | NodePath<t.TSTemplateLiteralType> | NodePath<t.TSThisType> | NodePath<t.TSTupleType> | NodePath<t.TSTypeAliasDeclaration> | NodePath<t.TSTypeAnnotation> | NodePath<t.TSTypeAssertion> | NodePath<t.TSTypeLiteral> | NodePath<t.TSTypeOperator> | NodePath<t.TSTypeParameter> | NodePath<t.TSTypeParameterDeclaration> | NodePath<t.TSTypeParameterInstantiation> | NodePath<t.TSTypePredicate> | NodePath<t.TSTypeQuery> | NodePath<t.TSTypeReference> | NodePath<t.TSUndefinedKeyword> | NodePath<t.TSUnionType> | NodePath<t.TSUnknownKeyword> | NodePath<t.TSVoidKeyword> | NodePath<t.TaggedTemplateExpression> | NodePath<t.TemplateElement> | NodePath<t.TemplateLiteral> | NodePath<t.ThisExpression> | NodePath<t.ThisTypeAnnotation> | NodePath<t.ThrowStatement> | NodePath<t.TopicReference> | NodePath<t.TryStatement> | NodePath<t.TupleExpression> | NodePath<t.TupleTypeAnnotation> | NodePath<t.TypeAlias> | NodePath<t.TypeAnnotation> | NodePath<t.TypeCastExpression> | NodePath<t.TypeParameter> | NodePath<t.TypeParameterDeclaration> | NodePath<t.TypeParameterInstantiation> | NodePath<t.TypeofTypeAnnotation> | NodePath<t.UnaryExpression> | NodePath<t.UnionTypeAnnotation> | NodePath<t.UpdateExpression> | NodePath<t.V8IntrinsicIdentifier> | NodePath<t.VariableDeclaration> | NodePath<t.VariableDeclarator> | NodePath<t.Variance> | NodePath<t.VoidTypeAnnotation> | NodePath<t.WhileStatement> | NodePath<t.WithStatement> | NodePath<t.YieldExpression>>;
3479
+ declare function getCachedPaths(path: NodePath_Final): Map<Node, NodePath<t.Identifier> | NodePath<t.AnyTypeAnnotation> | NodePath<t.ArgumentPlaceholder> | NodePath<t.ArrayExpression> | NodePath<t.ArrayPattern> | NodePath<t.ArrayTypeAnnotation> | NodePath<t.ArrowFunctionExpression> | NodePath<t.AssignmentExpression> | NodePath<t.AssignmentPattern> | NodePath<t.AwaitExpression> | NodePath<t.BigIntLiteral> | NodePath<t.BinaryExpression> | NodePath<t.BindExpression> | NodePath<t.BlockStatement> | NodePath<t.BooleanLiteral> | NodePath<t.BooleanLiteralTypeAnnotation> | NodePath<t.BooleanTypeAnnotation> | NodePath<t.BreakStatement> | NodePath<t.CallExpression> | NodePath<t.CatchClause> | NodePath<t.ClassAccessorProperty> | NodePath<t.ClassBody> | NodePath<t.ClassDeclaration> | NodePath<t.ClassExpression> | NodePath<t.ClassImplements> | NodePath<t.ClassMethod> | NodePath<t.ClassPrivateMethod> | NodePath<t.ClassPrivateProperty> | NodePath<t.ClassProperty> | NodePath<t.ConditionalExpression> | NodePath<t.ContinueStatement> | NodePath<t.DebuggerStatement> | NodePath<t.DeclareClass> | NodePath<t.DeclareExportAllDeclaration> | NodePath<t.DeclareExportDeclaration> | NodePath<t.DeclareFunction> | NodePath<t.DeclareInterface> | NodePath<t.DeclareModule> | NodePath<t.DeclareModuleExports> | NodePath<t.DeclareOpaqueType> | NodePath<t.DeclareTypeAlias> | NodePath<t.DeclareVariable> | NodePath<t.DeclaredPredicate> | NodePath<t.Decorator> | NodePath<t.Directive> | NodePath<t.DirectiveLiteral> | NodePath<t.DoExpression> | NodePath<t.DoWhileStatement> | NodePath<t.EmptyStatement> | NodePath<t.EmptyTypeAnnotation> | NodePath<t.EnumBooleanBody> | NodePath<t.EnumBooleanMember> | NodePath<t.EnumDeclaration> | NodePath<t.EnumDefaultedMember> | NodePath<t.EnumNumberBody> | NodePath<t.EnumNumberMember> | NodePath<t.EnumStringBody> | NodePath<t.EnumStringMember> | NodePath<t.EnumSymbolBody> | NodePath<t.ExistsTypeAnnotation> | NodePath<t.ExportAllDeclaration> | NodePath<t.ExportDefaultDeclaration> | NodePath<t.ExportDefaultSpecifier> | NodePath<t.ExportNamedDeclaration> | NodePath<t.ExportNamespaceSpecifier> | NodePath<t.ExportSpecifier> | NodePath<t.ExpressionStatement> | NodePath<t.File> | NodePath<t.ForInStatement> | NodePath<t.ForOfStatement> | NodePath<t.ForStatement> | NodePath<t.FunctionDeclaration> | NodePath<t.FunctionExpression> | NodePath<t.FunctionTypeAnnotation> | NodePath<t.FunctionTypeParam> | NodePath<t.GenericTypeAnnotation> | NodePath<t.IfStatement> | NodePath<t.Import> | NodePath<t.ImportAttribute> | NodePath<t.ImportDeclaration> | NodePath<t.ImportDefaultSpecifier> | NodePath<t.ImportExpression> | NodePath<t.ImportNamespaceSpecifier> | NodePath<t.ImportSpecifier> | NodePath<t.IndexedAccessType> | NodePath<t.InferredPredicate> | NodePath<t.InterfaceDeclaration> | NodePath<t.InterfaceExtends> | NodePath<t.InterfaceTypeAnnotation> | NodePath<t.InterpreterDirective> | NodePath<t.IntersectionTypeAnnotation> | NodePath<t.JSXAttribute> | NodePath<t.JSXClosingElement> | NodePath<t.JSXClosingFragment> | NodePath<t.JSXElement> | NodePath<t.JSXEmptyExpression> | NodePath<t.JSXExpressionContainer> | NodePath<t.JSXFragment> | NodePath<t.JSXIdentifier> | NodePath<t.JSXMemberExpression> | NodePath<t.JSXNamespacedName> | NodePath<t.JSXOpeningElement> | NodePath<t.JSXOpeningFragment> | NodePath<t.JSXSpreadAttribute> | NodePath<t.JSXSpreadChild> | NodePath<t.JSXText> | NodePath<t.LabeledStatement> | NodePath<t.LogicalExpression> | NodePath<t.MemberExpression> | NodePath<t.MetaProperty> | NodePath<t.MixedTypeAnnotation> | NodePath<t.ModuleExpression> | NodePath<t.NewExpression> | NodePath<t.NullLiteral> | NodePath<t.NullLiteralTypeAnnotation> | NodePath<t.NullableTypeAnnotation> | NodePath<t.NumberLiteral> | NodePath<t.NumberLiteralTypeAnnotation> | NodePath<t.NumberTypeAnnotation> | NodePath<t.NumericLiteral> | NodePath<t.ObjectExpression> | NodePath<t.ObjectMethod> | NodePath<t.ObjectPattern> | NodePath<t.ObjectProperty> | NodePath<t.ObjectTypeAnnotation> | NodePath<t.ObjectTypeCallProperty> | NodePath<t.ObjectTypeIndexer> | NodePath<t.ObjectTypeInternalSlot> | NodePath<t.ObjectTypeProperty> | NodePath<t.ObjectTypeSpreadProperty> | NodePath<t.OpaqueType> | NodePath<t.OptionalCallExpression> | NodePath<t.OptionalIndexedAccessType> | NodePath<t.OptionalMemberExpression> | NodePath<t.ParenthesizedExpression> | NodePath<t.PipelineBareFunction> | NodePath<t.PipelinePrimaryTopicReference> | NodePath<t.PipelineTopicExpression> | NodePath<t.Placeholder> | NodePath<t.PrivateName> | NodePath<t.Program> | NodePath<t.QualifiedTypeIdentifier> | NodePath<t.RecordExpression> | NodePath<t.RegExpLiteral> | NodePath<t.RegexLiteral> | NodePath<t.RestElement> | NodePath<t.RestProperty> | NodePath<t.ReturnStatement> | NodePath<t.SequenceExpression> | NodePath<t.SpreadElement> | NodePath<t.SpreadProperty> | NodePath<t.StaticBlock> | NodePath<t.StringLiteral> | NodePath<t.StringLiteralTypeAnnotation> | NodePath<t.StringTypeAnnotation> | NodePath<t.Super> | NodePath<t.SwitchCase> | NodePath<t.SwitchStatement> | NodePath<t.SymbolTypeAnnotation> | NodePath<t.TSAnyKeyword> | NodePath<t.TSArrayType> | NodePath<t.TSAsExpression> | NodePath<t.TSBigIntKeyword> | NodePath<t.TSBooleanKeyword> | NodePath<t.TSCallSignatureDeclaration> | NodePath<t.TSClassImplements> | NodePath<t.TSConditionalType> | NodePath<t.TSConstructSignatureDeclaration> | NodePath<t.TSConstructorType> | NodePath<t.TSDeclareFunction> | NodePath<t.TSDeclareMethod> | NodePath<t.TSEnumBody> | NodePath<t.TSEnumDeclaration> | NodePath<t.TSEnumMember> | NodePath<t.TSExportAssignment> | NodePath<t.TSExternalModuleReference> | NodePath<t.TSFunctionType> | NodePath<t.TSImportEqualsDeclaration> | NodePath<t.TSImportType> | NodePath<t.TSIndexSignature> | NodePath<t.TSIndexedAccessType> | NodePath<t.TSInferType> | NodePath<t.TSInstantiationExpression> | NodePath<t.TSInterfaceBody> | NodePath<t.TSInterfaceDeclaration> | NodePath<t.TSInterfaceHeritage> | NodePath<t.TSIntersectionType> | NodePath<t.TSIntrinsicKeyword> | NodePath<t.TSLiteralType> | NodePath<t.TSMappedType> | NodePath<t.TSMethodSignature> | NodePath<t.TSModuleBlock> | NodePath<t.TSModuleDeclaration> | NodePath<t.TSNamedTupleMember> | NodePath<t.TSNamespaceExportDeclaration> | NodePath<t.TSNeverKeyword> | NodePath<t.TSNonNullExpression> | NodePath<t.TSNullKeyword> | NodePath<t.TSNumberKeyword> | NodePath<t.TSObjectKeyword> | NodePath<t.TSOptionalType> | NodePath<t.TSParameterProperty> | NodePath<t.TSParenthesizedType> | NodePath<t.TSPropertySignature> | NodePath<t.TSQualifiedName> | NodePath<t.TSRestType> | NodePath<t.TSSatisfiesExpression> | NodePath<t.TSStringKeyword> | NodePath<t.TSSymbolKeyword> | NodePath<t.TSTemplateLiteralType> | NodePath<t.TSThisType> | NodePath<t.TSTupleType> | NodePath<t.TSTypeAliasDeclaration> | NodePath<t.TSTypeAnnotation> | NodePath<t.TSTypeAssertion> | NodePath<t.TSTypeLiteral> | NodePath<t.TSTypeOperator> | NodePath<t.TSTypeParameter> | NodePath<t.TSTypeParameterDeclaration> | NodePath<t.TSTypeParameterInstantiation> | NodePath<t.TSTypePredicate> | NodePath<t.TSTypeQuery> | NodePath<t.TSTypeReference> | NodePath<t.TSUndefinedKeyword> | NodePath<t.TSUnionType> | NodePath<t.TSUnknownKeyword> | NodePath<t.TSVoidKeyword> | NodePath<t.TaggedTemplateExpression> | NodePath<t.TemplateElement> | NodePath<t.TemplateLiteral> | NodePath<t.ThisExpression> | NodePath<t.ThisTypeAnnotation> | NodePath<t.ThrowStatement> | NodePath<t.TopicReference> | NodePath<t.TryStatement> | NodePath<t.TupleExpression> | NodePath<t.TupleTypeAnnotation> | NodePath<t.TypeAlias> | NodePath<t.TypeAnnotation> | NodePath<t.TypeCastExpression> | NodePath<t.TypeParameter> | NodePath<t.TypeParameterDeclaration> | NodePath<t.TypeParameterInstantiation> | NodePath<t.TypeofTypeAnnotation> | NodePath<t.UnaryExpression> | NodePath<t.UnionTypeAnnotation> | NodePath<t.UpdateExpression> | NodePath<t.V8IntrinsicIdentifier> | NodePath<t.VariableDeclaration> | NodePath<t.VariableDeclarator> | NodePath<t.Variance> | NodePath<t.VoidPattern> | NodePath<t.VoidTypeAnnotation> | NodePath<t.WhileStatement> | NodePath<t.WithStatement> | NodePath<t.YieldExpression>>;
3457
3480
  declare function getOrCreateCachedPaths(node: Node, parentPath?: NodePath_Final): Map<any, any>;
3458
3481
 
3459
3482
  declare const __cache_ts_clear: typeof clear;
@@ -3520,4 +3543,4 @@ declare namespace traverse {
3520
3543
  var cache: typeof __cache_ts;
3521
3544
  }
3522
3545
 
3523
- export { Binding, type ExplodedTraverseOptions, type ExplodedVisitor, Hub, type HubInterface, NodePath_Final as NodePath, Scope, type TraverseOptions, type Visitor, type VisitorBase, traverse as default, __visitors_ts as visitors };
3546
+ export { Binding, type ExplodedTraverseOptions, type ExplodedVisitor, Hub, type HubInterface, NodePath_Final as NodePath, Scope, type TraverseOptions, type VisitWrapper, type Visitor, type VisitorBase, traverse as default, __visitors_ts as visitors };
package/lib/index.js CHANGED
@@ -2,7 +2,8 @@ import buildDebug from 'debug';
2
2
  import { codeFrameColumns } from '@babel/code-frame';
3
3
  import * as _t from '@babel/types';
4
4
  import { parse } from '@babel/parser';
5
- import globals from 'globals';
5
+ import globalsBuiltinLower from '@babel/helper-globals/data/builtin-lower.json' with { type: 'json' };
6
+ import globalsBuiltinUpper from '@babel/helper-globals/data/builtin-upper.json' with { type: 'json' };
6
7
  import generator from '@babel/generator';
7
8
  import template from '@babel/template';
8
9
 
@@ -289,7 +290,7 @@ function verify$1(visitor) {
289
290
  }
290
291
  if (shouldIgnoreKey(nodeType)) continue;
291
292
  if (!TYPES.includes(nodeType)) {
292
- throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.0.0-beta.0"}`);
293
+ throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.0.0-beta.2"}`);
293
294
  }
294
295
  const visitors = visitor[nodeType];
295
296
  if (typeof visitors === "object") {
@@ -766,6 +767,7 @@ function gatherNodeParts(node, parts) {
766
767
  parts.push("super");
767
768
  break;
768
769
  case "Import":
770
+ case "ImportExpression":
769
771
  parts.push("import");
770
772
  break;
771
773
  case "DoExpression":
@@ -974,7 +976,7 @@ class Scope {
974
976
  this.labels = new Map();
975
977
  this.inited = false;
976
978
  }
977
- static globals = Object.keys(globals.builtin);
979
+ static globals = [...globalsBuiltinLower, ...globalsBuiltinUpper];
978
980
  static contextVariables = ["arguments", "undefined", "Infinity", "NaN"];
979
981
  get parent() {
980
982
  let parent,
@@ -2295,8 +2297,8 @@ function insertBefore(nodes_) {
2295
2297
  } else if (this.isStatementOrBlock()) {
2296
2298
  const node = this.node;
2297
2299
  const shouldInsertCurrentNode = node && (!this.isExpressionStatement() || node.expression != null);
2298
- this.replaceWith(blockStatement$2(shouldInsertCurrentNode ? [node] : []));
2299
- return this.unshiftContainer("body", nodes);
2300
+ const [blockPath] = this.replaceWith(blockStatement$2(shouldInsertCurrentNode ? [node] : []));
2301
+ return blockPath.unshiftContainer("body", nodes);
2300
2302
  } else {
2301
2303
  throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
2302
2304
  }
@@ -2395,8 +2397,8 @@ function insertAfter(nodes_) {
2395
2397
  } else if (this.isStatementOrBlock()) {
2396
2398
  const node = this.node;
2397
2399
  const shouldInsertCurrentNode = node && (!this.isExpressionStatement() || node.expression != null);
2398
- this.replaceWith(blockStatement$2(shouldInsertCurrentNode ? [node] : []));
2399
- return this.pushContainer("body", nodes);
2400
+ const [blockPath] = this.replaceWith(blockStatement$2(shouldInsertCurrentNode ? [node] : []));
2401
+ return blockPath.pushContainer("body", nodes);
2400
2402
  } else {
2401
2403
  throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
2402
2404
  }
@@ -2439,15 +2441,16 @@ function _verifyNodeList(nodes) {
2439
2441
  }
2440
2442
  function unshiftContainer(listKey, nodes) {
2441
2443
  _assertUnremoved.call(this);
2442
- nodes = _verifyNodeList.call(this, nodes);
2444
+ const verifiedNodes = _verifyNodeList.call(this, nodes);
2445
+ const container = this.node[listKey];
2443
2446
  const path = NodePath_Final.get({
2444
2447
  parentPath: this,
2445
2448
  parent: this.node,
2446
- container: this.node[listKey],
2449
+ container,
2447
2450
  listKey,
2448
2451
  key: 0
2449
2452
  }).setContext(this.context);
2450
- return _containerInsertBefore.call(path, nodes);
2453
+ return _containerInsertBefore.call(path, verifiedNodes);
2451
2454
  }
2452
2455
  function pushContainer(listKey, nodes) {
2453
2456
  _assertUnremoved.call(this);
@@ -2456,7 +2459,7 @@ function pushContainer(listKey, nodes) {
2456
2459
  const path = NodePath_Final.get({
2457
2460
  parentPath: this,
2458
2461
  parent: this.node,
2459
- container: container,
2462
+ container,
2460
2463
  listKey,
2461
2464
  key: container.length
2462
2465
  }).setContext(this.context);
@@ -2495,9 +2498,9 @@ const {
2495
2498
  } = _t;
2496
2499
  function replaceWithMultiple(nodes) {
2497
2500
  resync.call(this);
2498
- nodes = _verifyNodeList.call(this, nodes);
2499
- inheritLeadingComments(nodes[0], this.node);
2500
- inheritTrailingComments(nodes[nodes.length - 1], this.node);
2501
+ const verifiedNodes = _verifyNodeList.call(this, nodes);
2502
+ inheritLeadingComments(verifiedNodes[0], this.node);
2503
+ inheritTrailingComments(verifiedNodes[verifiedNodes.length - 1], this.node);
2501
2504
  getCachedPaths(this)?.delete(this.node);
2502
2505
  this.node = this.container[this.key] = null;
2503
2506
  const paths = this.insertAfter(nodes);