UNPKG

46.8 kBTypeScriptView Raw
1// Type definitions for babel-traverse 6.25
2// Project: https://github.com/babel/babel/tree/master/packages/babel-traverse, https://babeljs.io
3// Definitions by: Troy Gerwien <https://github.com/yortus>
4// Marvin Hagemeister <https://github.com/marvinhagemeister>
5// Ryan Petrich <https://github.com/rpetrich>
6// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7// TypeScript Version: 2.8
8
9import * as t from 'babel-types';
10export type Node = t.Node;
11
12export default function traverse<S>(parent: Node | Node[], opts: TraverseOptions<S>, scope: Scope, state: S, parentPath?: NodePath): void;
13export default function traverse(parent: Node | Node[], opts: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath): void;
14
15export interface TraverseOptions<S = Node> extends Visitor<S> {
16 scope?: Scope;
17 noScope?: boolean;
18}
19
20export class Scope {
21 constructor(path: NodePath, parentScope?: Scope);
22 path: NodePath;
23 block: Node;
24 parentBlock: Node;
25 parent: Scope;
26 hub: Hub;
27 bindings: { [name: string]: Binding; };
28
29 /** Traverse node with current scope and path. */
30 traverse<S>(node: Node | Node[], opts: TraverseOptions<S>, state: S): void;
31 traverse(node: Node | Node[], opts?: TraverseOptions, state?: any): void;
32
33 /** Generate a unique identifier and add it to the current scope. */
34 generateDeclaredUidIdentifier(name?: string): t.Identifier;
35
36 /** Generate a unique identifier. */
37 generateUidIdentifier(name?: string): t.Identifier;
38
39 /** Generate a unique `_id1` binding. */
40 generateUid(name?: string): string;
41
42 /** Generate a unique identifier based on a node. */
43 generateUidIdentifierBasedOnNode(parent: Node, defaultName?: string): t.Identifier;
44
45 /**
46 * Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
47 * evaluating it wont result in potentially arbitrary code from being ran. The following are
48 * whitelisted and determined not to cause side effects:
49 *
50 * - `this` expressions
51 * - `super` expressions
52 * - Bound identifiers
53 */
54 isStatic(node: Node): boolean;
55
56 /** Possibly generate a memoised identifier if it is not static and has consequences. */
57 maybeGenerateMemoised(node: Node, dontPush?: boolean): t.Identifier;
58
59 checkBlockScopedCollisions(local: Node, kind: string, name: string, id: object): void;
60
61 rename(oldName: string, newName?: string, block?: Node): void;
62
63 dump(): void;
64
65 toArray(node: Node, i?: number): Node;
66
67 registerDeclaration(path: NodePath): void;
68
69 buildUndefinedNode(): Node;
70
71 registerConstantViolation(path: NodePath): void;
72
73 registerBinding(kind: string, path: NodePath, bindingPath?: NodePath): void;
74
75 addGlobal(node: Node): void;
76
77 hasUid(name: string): boolean;
78
79 hasGlobal(name: string): boolean;
80
81 hasReference(name: string): boolean;
82
83 isPure(node: Node, constantsOnly?: boolean): boolean;
84
85 setData(key: string, val: any): any;
86
87 getData(key: string): any;
88
89 removeData(key: string): void;
90
91 push(opts: any): void;
92
93 getProgramParent(): Scope;
94
95 getFunctionParent(): Scope;
96
97 getBlockParent(): Scope;
98
99 /** Walks the scope tree and gathers **all** bindings. */
100 getAllBindings(...kinds: string[]): object;
101
102 bindingIdentifierEquals(name: string, node: Node): boolean;
103
104 getBinding(name: string): Binding | undefined;
105
106 getOwnBinding(name: string): Binding | undefined;
107
108 getBindingIdentifier(name: string): t.Identifier;
109
110 getOwnBindingIdentifier(name: string): t.Identifier;
111
112 hasOwnBinding(name: string): boolean;
113
114 hasBinding(name: string, noGlobals?: boolean): boolean;
115
116 parentHasBinding(name: string, noGlobals?: boolean): boolean;
117
118 /** Move a binding of `name` to another `scope`. */
119 moveBindingTo(name: string, scope: Scope): void;
120
121 removeOwnBinding(name: string): void;
122
123 removeBinding(name: string): void;
124}
125
126export class Binding {
127 constructor(opts: { existing: Binding; identifier: t.Identifier; scope: Scope; path: NodePath; kind: 'var' | 'let' | 'const'; });
128 identifier: t.Identifier;
129 scope: Scope;
130 path: NodePath;
131 kind: 'var' | 'let' | 'const' | 'module';
132 referenced: boolean;
133 references: number;
134 referencePaths: NodePath[];
135 constant: boolean;
136 constantViolations: NodePath[];
137}
138
139// The Visitor has to be generic because babel binds `this` for each property.
140// `this` is usually used in babel plugins to pass plugin state from
141// `pre` -> `visitor` -> `post`. An example of this can be seen in the official
142// babel handbook:
143// https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#-pre-and-post-in-plugins
144export interface Visitor<S = Node> extends VisitNodeObject<Node> {
145 ArrayExpression?: VisitNode<S, t.ArrayExpression>;
146 AssignmentExpression?: VisitNode<S, t.AssignmentExpression>;
147 LVal?: VisitNode<S, t.LVal>;
148 Expression?: VisitNode<S, t.Expression>;
149 BinaryExpression?: VisitNode<S, t.BinaryExpression>;
150 Directive?: VisitNode<S, t.Directive>;
151 DirectiveLiteral?: VisitNode<S, t.DirectiveLiteral>;
152 BlockStatement?: VisitNode<S, t.BlockStatement>;
153 BreakStatement?: VisitNode<S, t.BreakStatement>;
154 Identifier?: VisitNode<S, t.Identifier>;
155 CallExpression?: VisitNode<S, t.CallExpression>;
156 CatchClause?: VisitNode<S, t.CatchClause>;
157 ConditionalExpression?: VisitNode<S, t.ConditionalExpression>;
158 ContinueStatement?: VisitNode<S, t.ContinueStatement>;
159 DebuggerStatement?: VisitNode<S, t.DebuggerStatement>;
160 DoWhileStatement?: VisitNode<S, t.DoWhileStatement>;
161 Statement?: VisitNode<S, t.Statement>;
162 EmptyStatement?: VisitNode<S, t.EmptyStatement>;
163 ExpressionStatement?: VisitNode<S, t.ExpressionStatement>;
164 File?: VisitNode<S, t.File>;
165 Program?: VisitNode<S, t.Program>;
166 ForInStatement?: VisitNode<S, t.ForInStatement>;
167 VariableDeclaration?: VisitNode<S, t.VariableDeclaration>;
168 ForStatement?: VisitNode<S, t.ForStatement>;
169 FunctionDeclaration?: VisitNode<S, t.FunctionDeclaration>;
170 FunctionExpression?: VisitNode<S, t.FunctionExpression>;
171 IfStatement?: VisitNode<S, t.IfStatement>;
172 LabeledStatement?: VisitNode<S, t.LabeledStatement>;
173 StringLiteral?: VisitNode<S, t.StringLiteral>;
174 NumericLiteral?: VisitNode<S, t.NumericLiteral>;
175 NullLiteral?: VisitNode<S, t.NullLiteral>;
176 BooleanLiteral?: VisitNode<S, t.BooleanLiteral>;
177 RegExpLiteral?: VisitNode<S, t.RegExpLiteral>;
178 LogicalExpression?: VisitNode<S, t.LogicalExpression>;
179 MemberExpression?: VisitNode<S, t.MemberExpression>;
180 NewExpression?: VisitNode<S, t.NewExpression>;
181 ObjectExpression?: VisitNode<S, t.ObjectExpression>;
182 ObjectMethod?: VisitNode<S, t.ObjectMethod>;
183 ObjectProperty?: VisitNode<S, t.ObjectProperty>;
184 RestElement?: VisitNode<S, t.RestElement>;
185 ReturnStatement?: VisitNode<S, t.ReturnStatement>;
186 SequenceExpression?: VisitNode<S, t.SequenceExpression>;
187 SwitchCase?: VisitNode<S, t.SwitchCase>;
188 SwitchStatement?: VisitNode<S, t.SwitchStatement>;
189 ThisExpression?: VisitNode<S, t.ThisExpression>;
190 ThrowStatement?: VisitNode<S, t.ThrowStatement>;
191 TryStatement?: VisitNode<S, t.TryStatement>;
192 UnaryExpression?: VisitNode<S, t.UnaryExpression>;
193 UpdateExpression?: VisitNode<S, t.UpdateExpression>;
194 VariableDeclarator?: VisitNode<S, t.VariableDeclarator>;
195 WhileStatement?: VisitNode<S, t.WhileStatement>;
196 WithStatement?: VisitNode<S, t.WithStatement>;
197 AssignmentPattern?: VisitNode<S, t.AssignmentPattern>;
198 ArrayPattern?: VisitNode<S, t.ArrayPattern>;
199 ArrowFunctionExpression?: VisitNode<S, t.ArrowFunctionExpression>;
200 ClassBody?: VisitNode<S, t.ClassBody>;
201 ClassDeclaration?: VisitNode<S, t.ClassDeclaration>;
202 ClassExpression?: VisitNode<S, t.ClassExpression>;
203 ExportAllDeclaration?: VisitNode<S, t.ExportAllDeclaration>;
204 ExportDefaultDeclaration?: VisitNode<S, t.ExportDefaultDeclaration>;
205 ExportNamedDeclaration?: VisitNode<S, t.ExportNamedDeclaration>;
206 Declaration?: VisitNode<S, t.Declaration>;
207 ExportSpecifier?: VisitNode<S, t.ExportSpecifier>;
208 ForOfStatement?: VisitNode<S, t.ForOfStatement>;
209 ImportDeclaration?: VisitNode<S, t.ImportDeclaration>;
210 ImportDefaultSpecifier?: VisitNode<S, t.ImportDefaultSpecifier>;
211 ImportNamespaceSpecifier?: VisitNode<S, t.ImportNamespaceSpecifier>;
212 ImportSpecifier?: VisitNode<S, t.ImportSpecifier>;
213 MetaProperty?: VisitNode<S, t.MetaProperty>;
214 ClassMethod?: VisitNode<S, t.ClassMethod>;
215 ObjectPattern?: VisitNode<S, t.ObjectPattern>;
216 SpreadElement?: VisitNode<S, t.SpreadElement>;
217 Super?: VisitNode<S, t.Super>;
218 TaggedTemplateExpression?: VisitNode<S, t.TaggedTemplateExpression>;
219 TemplateLiteral?: VisitNode<S, t.TemplateLiteral>;
220 TemplateElement?: VisitNode<S, t.TemplateElement>;
221 YieldExpression?: VisitNode<S, t.YieldExpression>;
222 AnyTypeAnnotation?: VisitNode<S, t.AnyTypeAnnotation>;
223 ArrayTypeAnnotation?: VisitNode<S, t.ArrayTypeAnnotation>;
224 BooleanTypeAnnotation?: VisitNode<S, t.BooleanTypeAnnotation>;
225 BooleanLiteralTypeAnnotation?: VisitNode<S, t.BooleanLiteralTypeAnnotation>;
226 NullLiteralTypeAnnotation?: VisitNode<S, t.NullLiteralTypeAnnotation>;
227 ClassImplements?: VisitNode<S, t.ClassImplements>;
228 ClassProperty?: VisitNode<S, t.ClassProperty>;
229 DeclareClass?: VisitNode<S, t.DeclareClass>;
230 DeclareFunction?: VisitNode<S, t.DeclareFunction>;
231 DeclareInterface?: VisitNode<S, t.DeclareInterface>;
232 DeclareModule?: VisitNode<S, t.DeclareModule>;
233 DeclareTypeAlias?: VisitNode<S, t.DeclareTypeAlias>;
234 DeclareVariable?: VisitNode<S, t.DeclareVariable>;
235 ExistentialTypeParam?: VisitNode<S, t.ExistentialTypeParam>;
236 FunctionTypeAnnotation?: VisitNode<S, t.FunctionTypeAnnotation>;
237 FunctionTypeParam?: VisitNode<S, t.FunctionTypeParam>;
238 GenericTypeAnnotation?: VisitNode<S, t.GenericTypeAnnotation>;
239 InterfaceExtends?: VisitNode<S, t.InterfaceExtends>;
240 InterfaceDeclaration?: VisitNode<S, t.InterfaceDeclaration>;
241 IntersectionTypeAnnotation?: VisitNode<S, t.IntersectionTypeAnnotation>;
242 MixedTypeAnnotation?: VisitNode<S, t.MixedTypeAnnotation>;
243 NullableTypeAnnotation?: VisitNode<S, t.NullableTypeAnnotation>;
244 NumericLiteralTypeAnnotation?: VisitNode<S, t.NumericLiteralTypeAnnotation>;
245 NumberTypeAnnotation?: VisitNode<S, t.NumberTypeAnnotation>;
246 StringLiteralTypeAnnotation?: VisitNode<S, t.StringLiteralTypeAnnotation>;
247 StringTypeAnnotation?: VisitNode<S, t.StringTypeAnnotation>;
248 ThisTypeAnnotation?: VisitNode<S, t.ThisTypeAnnotation>;
249 TupleTypeAnnotation?: VisitNode<S, t.TupleTypeAnnotation>;
250 TypeofTypeAnnotation?: VisitNode<S, t.TypeofTypeAnnotation>;
251 TypeAlias?: VisitNode<S, t.TypeAlias>;
252 TypeAnnotation?: VisitNode<S, t.TypeAnnotation>;
253 TypeCastExpression?: VisitNode<S, t.TypeCastExpression>;
254 TypeParameterDeclaration?: VisitNode<S, t.TypeParameterDeclaration>;
255 TypeParameterInstantiation?: VisitNode<S, t.TypeParameterInstantiation>;
256 ObjectTypeAnnotation?: VisitNode<S, t.ObjectTypeAnnotation>;
257 ObjectTypeCallProperty?: VisitNode<S, t.ObjectTypeCallProperty>;
258 ObjectTypeIndexer?: VisitNode<S, t.ObjectTypeIndexer>;
259 ObjectTypeProperty?: VisitNode<S, t.ObjectTypeProperty>;
260 QualifiedTypeIdentifier?: VisitNode<S, t.QualifiedTypeIdentifier>;
261 UnionTypeAnnotation?: VisitNode<S, t.UnionTypeAnnotation>;
262 VoidTypeAnnotation?: VisitNode<S, t.VoidTypeAnnotation>;
263 JSXAttribute?: VisitNode<S, t.JSXAttribute>;
264 JSXIdentifier?: VisitNode<S, t.JSXIdentifier>;
265 JSXNamespacedName?: VisitNode<S, t.JSXNamespacedName>;
266 JSXElement?: VisitNode<S, t.JSXElement>;
267 JSXExpressionContainer?: VisitNode<S, t.JSXExpressionContainer>;
268 JSXClosingElement?: VisitNode<S, t.JSXClosingElement>;
269 JSXMemberExpression?: VisitNode<S, t.JSXMemberExpression>;
270 JSXOpeningElement?: VisitNode<S, t.JSXOpeningElement>;
271 JSXEmptyExpression?: VisitNode<S, t.JSXEmptyExpression>;
272 JSXSpreadAttribute?: VisitNode<S, t.JSXSpreadAttribute>;
273 JSXText?: VisitNode<S, t.JSXText>;
274 Noop?: VisitNode<S, t.Noop>;
275 ParenthesizedExpression?: VisitNode<S, t.ParenthesizedExpression>;
276 AwaitExpression?: VisitNode<S, t.AwaitExpression>;
277 BindExpression?: VisitNode<S, t.BindExpression>;
278 Decorator?: VisitNode<S, t.Decorator>;
279 DoExpression?: VisitNode<S, t.DoExpression>;
280 ExportDefaultSpecifier?: VisitNode<S, t.ExportDefaultSpecifier>;
281 ExportNamespaceSpecifier?: VisitNode<S, t.ExportNamespaceSpecifier>;
282 RestProperty?: VisitNode<S, t.RestProperty>;
283 SpreadProperty?: VisitNode<S, t.SpreadProperty>;
284 Binary?: VisitNode<S, t.Binary>;
285 Scopable?: VisitNode<S, t.Scopable>;
286 BlockParent?: VisitNode<S, t.BlockParent>;
287 Block?: VisitNode<S, t.Block>;
288 Terminatorless?: VisitNode<S, t.Terminatorless>;
289 CompletionStatement?: VisitNode<S, t.CompletionStatement>;
290 Conditional?: VisitNode<S, t.Conditional>;
291 Loop?: VisitNode<S, t.Loop>;
292 While?: VisitNode<S, t.While>;
293 ExpressionWrapper?: VisitNode<S, t.ExpressionWrapper>;
294 For?: VisitNode<S, t.For>;
295 ForXStatement?: VisitNode<S, t.ForXStatement>;
296 Function?: VisitNode<S, t.Function>;
297 FunctionParent?: VisitNode<S, t.FunctionParent>;
298 Pureish?: VisitNode<S, t.Pureish>;
299 Literal?: VisitNode<S, t.Literal>;
300 Immutable?: VisitNode<S, t.Immutable>;
301 UserWhitespacable?: VisitNode<S, t.UserWhitespacable>;
302 Method?: VisitNode<S, t.Method>;
303 ObjectMember?: VisitNode<S, t.ObjectMember>;
304 Property?: VisitNode<S, t.Property>;
305 UnaryLike?: VisitNode<S, t.UnaryLike>;
306 Pattern?: VisitNode<S, t.Pattern>;
307 Class?: VisitNode<S, t.Class>;
308 ModuleDeclaration?: VisitNode<S, t.ModuleDeclaration>;
309 ExportDeclaration?: VisitNode<S, t.ExportDeclaration>;
310 ModuleSpecifier?: VisitNode<S, t.ModuleSpecifier>;
311 Flow?: VisitNode<S, t.Flow>;
312 FlowBaseAnnotation?: VisitNode<S, t.FlowBaseAnnotation>;
313 FlowDeclaration?: VisitNode<S, t.FlowDeclaration>;
314 JSX?: VisitNode<S, t.JSX>;
315 Scope?: VisitNode<S, t.Scopable>;
316}
317
318export type VisitNode<T, P> = VisitNodeFunction<T, P> | VisitNodeObject<T>;
319
320export type VisitNodeFunction<T, P> = (this: T, path: NodePath<P>, state: any) => void;
321
322export interface VisitNodeObject<T> {
323 enter?(path: NodePath<T>, state: any): void;
324 exit?(path: NodePath<T>, state: any): void;
325}
326
327export class NodePath<T = Node> {
328 constructor(hub: Hub, parent: Node);
329 parent: Node;
330 hub: Hub;
331 contexts: TraversalContext[];
332 data: object;
333 shouldSkip: boolean;
334 shouldStop: boolean;
335 removed: boolean;
336 state: any;
337 opts: object;
338 skipKeys: object;
339 parentPath: NodePath;
340 context: TraversalContext;
341 container: object | object[];
342 listKey: string;
343 inList: boolean;
344 parentKey: string;
345 key: string | number;
346 node: T;
347 scope: Scope;
348 type: T extends undefined | null ? string | null : string;
349 typeAnnotation: object;
350
351 getScope(scope: Scope): Scope;
352
353 setData(key: string, val: any): any;
354
355 getData(key: string, def?: any): any;
356
357 buildCodeFrameError<TError extends Error>(msg: string, Error?: new (msg: string) => TError): TError;
358
359 traverse<T>(visitor: Visitor<T>, state: T): void;
360 traverse(visitor: Visitor): void;
361
362 set(key: string, node: Node): void;
363
364 getPathLocation(): string;
365
366 // Example: https://github.com/babel/babel/blob/63204ae51e020d84a5b246312f5eeb4d981ab952/packages/babel-traverse/src/path/modification.js#L83
367 debug(buildMessage: () => string): void;
368
369 // ------------------------- ancestry -------------------------
370 /**
371 * Call the provided `callback` with the `NodePath`s of all the parents.
372 * When the `callback` returns a truthy value, we return that node path.
373 */
374 findParent(callback: (path: NodePath) => boolean): NodePath;
375
376 find(callback: (path: NodePath) => boolean): NodePath;
377
378 /** Get the parent function of the current path. */
379 getFunctionParent(): NodePath<t.Function>;
380
381 /** Walk up the tree until we hit a parent node path in a list. */
382 getStatementParent(): NodePath<t.Statement>;
383
384 /**
385 * Get the deepest common ancestor and then from it, get the earliest relationship path
386 * to that ancestor.
387 *
388 * Earliest is defined as being "before" all the other nodes in terms of list container
389 * position and visiting key.
390 */
391 getEarliestCommonAncestorFrom(paths: NodePath[]): NodePath[];
392
393 /** Get the earliest path in the tree where the provided `paths` intersect. */
394 getDeepestCommonAncestorFrom(
395 paths: NodePath[],
396 filter?: (deepest: Node, i: number, ancestries: NodePath[]) => NodePath
397 ): NodePath;
398
399 /**
400 * Build an array of node paths containing the entire ancestry of the current node path.
401 *
402 * NOTE: The current node path is included in this.
403 */
404 getAncestry(): NodePath[];
405
406 inType(...candidateTypes: string[]): boolean;
407
408 // ------------------------- inference -------------------------
409 /** Infer the type of the current `NodePath`. */
410 getTypeAnnotation(): t.FlowTypeAnnotation;
411
412 isBaseType(baseName: string, soft?: boolean): boolean;
413
414 couldBeBaseType(name: string): boolean;
415
416 baseTypeStrictlyMatches(right: NodePath): boolean;
417
418 isGenericType(genericName: string): boolean;
419
420 // ------------------------- replacement -------------------------
421 /**
422 * Replace a node with an array of multiple. This method performs the following steps:
423 *
424 * - Inherit the comments of first provided node with that of the current node.
425 * - Insert the provided nodes after the current node.
426 * - Remove the current node.
427 */
428 replaceWithMultiple(nodes: Node[]): void;
429
430 /**
431 * Parse a string as an expression and replace the current node with the result.
432 *
433 * NOTE: This is typically not a good idea to use. Building source strings when
434 * transforming ASTs is an antipattern and SHOULD NOT be encouraged. Even if it's
435 * easier to use, your transforms will be extremely brittle.
436 */
437 replaceWithSourceString(replacement: any): void;
438
439 /** Replace the current node with another. */
440 replaceWith(replacement: Node | NodePath): void;
441
442 /**
443 * This method takes an array of statements nodes and then explodes it
444 * into expressions. This method retains completion records which is
445 * extremely important to retain original semantics.
446 */
447 replaceExpressionWithStatements(nodes: Node[]): Node;
448
449 replaceInline(nodes: Node | Node[]): void;
450
451 // ------------------------- evaluation -------------------------
452 /**
453 * Walk the input `node` and statically evaluate if it's truthy.
454 *
455 * Returning `true` when we're sure that the expression will evaluate to a
456 * truthy value, `false` if we're sure that it will evaluate to a falsy
457 * value and `undefined` if we aren't sure. Because of this please do not
458 * rely on coercion when using this method and check with === if it's false.
459 */
460 evaluateTruthy(): boolean;
461
462 /**
463 * Walk the input `node` and statically evaluate it.
464 *
465 * Returns an object in the form `{ confident, value }`. `confident` indicates
466 * whether or not we had to drop out of evaluating the expression because of
467 * hitting an unknown node that we couldn't confidently find the value of.
468 *
469 * Example:
470 *
471 * t.evaluate(parse("5 + 5")) // { confident: true, value: 10 }
472 * t.evaluate(parse("!true")) // { confident: true, value: false }
473 * t.evaluate(parse("foo + foo")) // { confident: false, value: undefined }
474 */
475 evaluate(): { confident: boolean; value: any };
476
477 // ------------------------- introspection -------------------------
478 /**
479 * Match the current node if it matches the provided `pattern`.
480 *
481 * For example, given the match `React.createClass` it would match the
482 * parsed nodes of `React.createClass` and `React["createClass"]`.
483 */
484 matchesPattern(pattern: string, allowPartial?: boolean): boolean;
485
486 /**
487 * Check whether we have the input `key`. If the `key` references an array then we check
488 * if the array has any items, otherwise we just check if it's falsy.
489 */
490 has(key: string): boolean;
491
492 isStatic(): boolean;
493
494 /** Alias of `has`. */
495 is(key: string): boolean;
496
497 /** Opposite of `has`. */
498 isnt(key: string): boolean;
499
500 /** Check whether the path node `key` strict equals `value`. */
501 equals(key: string, value: any): boolean;
502
503 /**
504 * Check the type against our stored internal type of the node. This is handy when a node has
505 * been removed yet we still internally know the type and need it to calculate node replacement.
506 */
507 isNodeType(type: string): boolean;
508
509 /**
510 * This checks whether or not we're in one of the following positions:
511 *
512 * for (KEY in right);
513 * for (KEY;;);
514 *
515 * This is because these spots allow VariableDeclarations AND normal expressions so we need
516 * to tell the path replacement that it's ok to replace this with an expression.
517 */
518 canHaveVariableDeclarationOrExpression(): boolean;
519
520 /**
521 * This checks whether we are swapping an arrow function's body between an
522 * expression and a block statement (or vice versa).
523 *
524 * This is because arrow functions may implicitly return an expression, which
525 * is the same as containing a block statement.
526 */
527 canSwapBetweenExpressionAndStatement(replacement: Node): boolean;
528
529 /** Check whether the current path references a completion record */
530 isCompletionRecord(allowInsideFunction?: boolean): boolean;
531
532 /**
533 * Check whether or not the current `key` allows either a single statement or block statement
534 * so we can explode it if necessary.
535 */
536 isStatementOrBlock(): boolean;
537
538 /** Check if the currently assigned path references the `importName` of `moduleSource`. */
539 referencesImport(moduleSource: string, importName: string): boolean;
540
541 /** Get the source code associated with this node. */
542 getSource(): string;
543
544 /** Check if the current path will maybe execute before another path */
545 willIMaybeExecuteBefore(path: NodePath): boolean;
546
547 // ------------------------- context -------------------------
548 call(key: string): boolean;
549
550 isBlacklisted(): boolean;
551
552 visit(): boolean;
553
554 skip(): void;
555
556 skipKey(key: string): void;
557
558 stop(): void;
559
560 setScope(): void;
561
562 setContext(context: TraversalContext): NodePath<T>;
563
564 popContext(): void;
565
566 pushContext(context: TraversalContext): void;
567
568 // ------------------------- removal -------------------------
569 remove(): void;
570
571 // ------------------------- modification -------------------------
572 /** Insert the provided nodes before the current one. */
573 insertBefore(nodes: Node | Node[]): any;
574
575 /**
576 * Insert the provided nodes after the current one. When inserting nodes after an
577 * expression, ensure that the completion record is correct by pushing the current node.
578 */
579 insertAfter(nodes: Node | Node[]): any;
580
581 /** Update all sibling node paths after `fromIndex` by `incrementBy`. */
582 updateSiblingKeys(fromIndex: number, incrementBy: number): void;
583
584 /** Hoist the current node to the highest scope possible and return a UID referencing it. */
585 hoist(scope: Scope): void;
586
587 // ------------------------- family -------------------------
588 getOpposite(): NodePath;
589
590 getCompletionRecords(): NodePath[];
591
592 getSibling(key: string | number): NodePath;
593 getAllPrevSiblings(): NodePath[];
594 getAllNextSiblings(): NodePath[];
595
596 get<K extends keyof T>(key: K, context?: boolean | TraversalContext):
597 T[K] extends Array<Node | null | undefined> ? Array<NodePath<T[K][number]>> :
598 T[K] extends Node | null | undefined ? NodePath<T[K]> :
599 never;
600 get(key: string, context?: boolean | TraversalContext): NodePath | NodePath[];
601
602 getBindingIdentifiers(duplicates?: boolean): Node[];
603
604 getOuterBindingIdentifiers(duplicates?: boolean): Node[];
605
606 // ------------------------- comments -------------------------
607 /** Share comments amongst siblings. */
608 shareCommentsWithSiblings(): void;
609
610 addComment(type: string, content: string, line?: boolean): void;
611
612 /** Give node `comments` of the specified `type`. */
613 addComments(type: string, comments: any[]): void;
614
615 // ------------------------- isXXX -------------------------
616 isArrayExpression(opts?: object): this is NodePath<t.ArrayExpression> ;
617 isAssignmentExpression(opts?: object): this is NodePath<t.AssignmentExpression>;
618 isBinaryExpression(opts?: object): this is NodePath<t.BinaryExpression>;
619 isDirective(opts?: object): this is NodePath<t.Directive>;
620 isDirectiveLiteral(opts?: object): this is NodePath<t.DirectiveLiteral>;
621 isBlockStatement(opts?: object): this is NodePath<t.BlockStatement>;
622 isBreakStatement(opts?: object): this is NodePath<t.BreakStatement>;
623 isCallExpression(opts?: object): this is NodePath<t.CallExpression>;
624 isCatchClause(opts?: object): this is NodePath<t.CatchClause>;
625 isConditionalExpression(opts?: object): this is NodePath<t.ConditionalExpression>;
626 isContinueStatement(opts?: object): this is NodePath<t.ContinueStatement>;
627 isDebuggerStatement(opts?: object): this is NodePath<t.DebuggerStatement>;
628 isDoWhileStatement(opts?: object): this is NodePath<t.DoWhileStatement>;
629 isEmptyStatement(opts?: object): this is NodePath<t.EmptyStatement>;
630 isExpressionStatement(opts?: object): this is NodePath<t.ExpressionStatement>;
631 isFile(opts?: object): this is NodePath<t.File>;
632 isForInStatement(opts?: object): this is NodePath<t.ForInStatement>;
633 isForStatement(opts?: object): this is NodePath<t.ForStatement>;
634 isFunctionDeclaration(opts?: object): this is NodePath<t.FunctionDeclaration>;
635 isFunctionExpression(opts?: object): this is NodePath<t.FunctionExpression>;
636 isIdentifier(opts?: object): this is NodePath<t.Identifier>;
637 isIfStatement(opts?: object): this is NodePath<t.IfStatement>;
638 isLabeledStatement(opts?: object): this is NodePath<t.LabeledStatement>;
639 isStringLiteral(opts?: object): this is NodePath<t.StringLiteral>;
640 isNumericLiteral(opts?: object): this is NodePath<t.NumericLiteral>;
641 isNullLiteral(opts?: object): this is NodePath<t.NullLiteral>;
642 isBooleanLiteral(opts?: object): this is NodePath<t.BooleanLiteral>;
643 isRegExpLiteral(opts?: object): this is NodePath<t.RegExpLiteral>;
644 isLogicalExpression(opts?: object): this is NodePath<t.LogicalExpression>;
645 isMemberExpression(opts?: object): this is NodePath<t.MemberExpression>;
646 isNewExpression(opts?: object): this is NodePath<t.NewExpression>;
647 isProgram(opts?: object): this is NodePath<t.Program>;
648 isObjectExpression(opts?: object): this is NodePath<t.ObjectExpression>;
649 isObjectMethod(opts?: object): this is NodePath<t.ObjectMethod>;
650 isObjectProperty(opts?: object): this is NodePath<t.ObjectProperty>;
651 isRestElement(opts?: object): this is NodePath<t.RestElement>;
652 isReturnStatement(opts?: object): this is NodePath<t.ReturnStatement>;
653 isSequenceExpression(opts?: object): this is NodePath<t.SequenceExpression>;
654 isSwitchCase(opts?: object): this is NodePath<t.SwitchCase>;
655 isSwitchStatement(opts?: object): this is NodePath<t.SwitchStatement>;
656 isThisExpression(opts?: object): this is NodePath<t.ThisExpression>;
657 isThrowStatement(opts?: object): this is NodePath<t.ThrowStatement>;
658 isTryStatement(opts?: object): this is NodePath<t.TryStatement>;
659 isUnaryExpression(opts?: object): this is NodePath<t.UnaryExpression>;
660 isUpdateExpression(opts?: object): this is NodePath<t.UpdateExpression>;
661 isVariableDeclaration(opts?: object): this is NodePath<t.VariableDeclaration>;
662 isVariableDeclarator(opts?: object): this is NodePath<t.VariableDeclarator>;
663 isWhileStatement(opts?: object): this is NodePath<t.WhileStatement>;
664 isWithStatement(opts?: object): this is NodePath<t.WithStatement>;
665 isAssignmentPattern(opts?: object): this is NodePath<t.AssignmentPattern>;
666 isArrayPattern(opts?: object): this is NodePath<t.ArrayPattern>;
667 isArrowFunctionExpression(opts?: object): this is NodePath<t.ArrowFunctionExpression>;
668 isClassBody(opts?: object): this is NodePath<t.ClassBody>;
669 isClassDeclaration(opts?: object): this is NodePath<t.ClassDeclaration>;
670 isClassExpression(opts?: object): this is NodePath<t.ClassExpression>;
671 isExportAllDeclaration(opts?: object): this is NodePath<t.ExportAllDeclaration>;
672 isExportDefaultDeclaration(opts?: object): this is NodePath<t.ExportDefaultDeclaration>;
673 isExportNamedDeclaration(opts?: object): this is NodePath<t.ExportNamedDeclaration>;
674 isExportSpecifier(opts?: object): this is NodePath<t.ExportSpecifier>;
675 isForOfStatement(opts?: object): this is NodePath<t.ForOfStatement>;
676 isImportDeclaration(opts?: object): this is NodePath<t.ImportDeclaration>;
677 isImportDefaultSpecifier(opts?: object): this is NodePath<t.ImportDefaultSpecifier>;
678 isImportNamespaceSpecifier(opts?: object): this is NodePath<t.ImportNamespaceSpecifier>;
679 isImportSpecifier(opts?: object): this is NodePath<t.ImportSpecifier>;
680 isMetaProperty(opts?: object): this is NodePath<t.MetaProperty>;
681 isClassMethod(opts?: object): this is NodePath<t.ClassMethod>;
682 isObjectPattern(opts?: object): this is NodePath<t.ObjectPattern>;
683 isSpreadElement(opts?: object): this is NodePath<t.SpreadElement>;
684 isSuper(opts?: object): this is NodePath<t.Super>;
685 isTaggedTemplateExpression(opts?: object): this is NodePath<t.TaggedTemplateExpression>;
686 isTemplateElement(opts?: object): this is NodePath<t.TemplateElement>;
687 isTemplateLiteral(opts?: object): this is NodePath<t.TemplateLiteral>;
688 isYieldExpression(opts?: object): this is NodePath<t.YieldExpression>;
689 isAnyTypeAnnotation(opts?: object): this is NodePath<t.AnyTypeAnnotation>;
690 isArrayTypeAnnotation(opts?: object): this is NodePath<t.ArrayTypeAnnotation>;
691 isBooleanTypeAnnotation(opts?: object): this is NodePath<t.BooleanTypeAnnotation>;
692 isBooleanLiteralTypeAnnotation(opts?: object): this is NodePath<t.BooleanLiteralTypeAnnotation>;
693 isNullLiteralTypeAnnotation(opts?: object): this is NodePath<t.NullLiteralTypeAnnotation>;
694 isClassImplements(opts?: object): this is NodePath<t.ClassImplements>;
695 isClassProperty(opts?: object): this is NodePath<t.ClassProperty>;
696 isDeclareClass(opts?: object): this is NodePath<t.DeclareClass>;
697 isDeclareFunction(opts?: object): this is NodePath<t.DeclareFunction>;
698 isDeclareInterface(opts?: object): this is NodePath<t.DeclareInterface>;
699 isDeclareModule(opts?: object): this is NodePath<t.DeclareModule>;
700 isDeclareTypeAlias(opts?: object): this is NodePath<t.DeclareTypeAlias>;
701 isDeclareVariable(opts?: object): this is NodePath<t.DeclareVariable>;
702 isExistentialTypeParam(opts?: object): this is NodePath<t.ExistentialTypeParam>;
703 isFunctionTypeAnnotation(opts?: object): this is NodePath<t.FunctionTypeAnnotation>;
704 isFunctionTypeParam(opts?: object): this is NodePath<t.FunctionTypeParam>;
705 isGenericTypeAnnotation(opts?: object): this is NodePath<t.GenericTypeAnnotation>;
706 isInterfaceExtends(opts?: object): this is NodePath<t.InterfaceExtends>;
707 isInterfaceDeclaration(opts?: object): this is NodePath<t.InterfaceDeclaration>;
708 isIntersectionTypeAnnotation(opts?: object): this is NodePath<t.IntersectionTypeAnnotation>;
709 isMixedTypeAnnotation(opts?: object): this is NodePath<t.MixedTypeAnnotation>;
710 isNullableTypeAnnotation(opts?: object): this is NodePath<t.NullableTypeAnnotation>;
711 isNumericLiteralTypeAnnotation(opts?: object): this is NodePath<t.NumericLiteralTypeAnnotation>;
712 isNumberTypeAnnotation(opts?: object): this is NodePath<t.NumberTypeAnnotation>;
713 isStringLiteralTypeAnnotation(opts?: object): this is NodePath<t.StringLiteralTypeAnnotation>;
714 isStringTypeAnnotation(opts?: object): this is NodePath<t.StringTypeAnnotation>;
715 isThisTypeAnnotation(opts?: object): this is NodePath<t.ThisTypeAnnotation>;
716 isTupleTypeAnnotation(opts?: object): this is NodePath<t.TupleTypeAnnotation>;
717 isTypeofTypeAnnotation(opts?: object): this is NodePath<t.TypeofTypeAnnotation>;
718 isTypeAlias(opts?: object): this is NodePath<t.TypeAlias>;
719 isTypeAnnotation(opts?: object): this is NodePath<t.TypeAnnotation>;
720 isTypeCastExpression(opts?: object): this is NodePath<t.TypeCastExpression>;
721 isTypeParameterDeclaration(opts?: object): this is NodePath<t.TypeParameterDeclaration>;
722 isTypeParameterInstantiation(opts?: object): this is NodePath<t.TypeParameterInstantiation>;
723 isObjectTypeAnnotation(opts?: object): this is NodePath<t.ObjectTypeAnnotation>;
724 isObjectTypeCallProperty(opts?: object): this is NodePath<t.ObjectTypeCallProperty>;
725 isObjectTypeIndexer(opts?: object): this is NodePath<t.ObjectTypeIndexer>;
726 isObjectTypeProperty(opts?: object): this is NodePath<t.ObjectTypeProperty>;
727 isQualifiedTypeIdentifier(opts?: object): this is NodePath<t.QualifiedTypeIdentifier>;
728 isUnionTypeAnnotation(opts?: object): this is NodePath<t.UnionTypeAnnotation>;
729 isVoidTypeAnnotation(opts?: object): this is NodePath<t.VoidTypeAnnotation>;
730 isJSXAttribute(opts?: object): this is NodePath<t.JSXAttribute>;
731 isJSXClosingElement(opts?: object): this is NodePath<t.JSXClosingElement>;
732 isJSXElement(opts?: object): this is NodePath<t.JSXElement>;
733 isJSXEmptyExpression(opts?: object): this is NodePath<t.JSXEmptyExpression>;
734 isJSXExpressionContainer(opts?: object): this is NodePath<t.JSXExpressionContainer>;
735 isJSXIdentifier(opts?: object): this is NodePath<t.JSXIdentifier>;
736 isJSXMemberExpression(opts?: object): this is NodePath<t.JSXMemberExpression>;
737 isJSXNamespacedName(opts?: object): this is NodePath<t.JSXNamespacedName>;
738 isJSXOpeningElement(opts?: object): this is NodePath<t.JSXOpeningElement>;
739 isJSXSpreadAttribute(opts?: object): this is NodePath<t.JSXSpreadAttribute>;
740 isJSXText(opts?: object): this is NodePath<t.JSXText>;
741 isNoop(opts?: object): this is NodePath<t.Noop>;
742 isParenthesizedExpression(opts?: object): this is NodePath<t.ParenthesizedExpression>;
743 isAwaitExpression(opts?: object): this is NodePath<t.AwaitExpression>;
744 isBindExpression(opts?: object): this is NodePath<t.BindExpression>;
745 isDecorator(opts?: object): this is NodePath<t.Decorator>;
746 isDoExpression(opts?: object): this is NodePath<t.DoExpression>;
747 isExportDefaultSpecifier(opts?: object): this is NodePath<t.ExportDefaultSpecifier>;
748 isExportNamespaceSpecifier(opts?: object): this is NodePath<t.ExportNamespaceSpecifier>;
749 isRestProperty(opts?: object): this is NodePath<t.RestProperty>;
750 isSpreadProperty(opts?: object): this is NodePath<t.SpreadProperty>;
751 isExpression(opts?: object): this is NodePath<t.Expression>;
752 isBinary(opts?: object): this is NodePath<t.Binary>;
753 isScopable(opts?: object): this is NodePath<t.Scopable>;
754 isBlockParent(opts?: object): this is NodePath<t.BlockParent>;
755 isBlock(opts?: object): this is NodePath<t.Block>;
756 isStatement(opts?: object): this is NodePath<t.Statement>;
757 isTerminatorless(opts?: object): this is NodePath<t.Terminatorless>;
758 isCompletionStatement(opts?: object): this is NodePath<t.CompletionStatement>;
759 isConditional(opts?: object): this is NodePath<t.Conditional>;
760 isLoop(opts?: object): this is NodePath<t.Loop>;
761 isWhile(opts?: object): this is NodePath<t.While>;
762 isExpressionWrapper(opts?: object): this is NodePath<t.ExpressionWrapper>;
763 isFor(opts?: object): this is NodePath<t.For>;
764 isForXStatement(opts?: object): this is NodePath<t.ForXStatement>;
765 isFunction(opts?: object): this is NodePath<t.Function>;
766 isFunctionParent(opts?: object): this is NodePath<t.FunctionParent>;
767 isPureish(opts?: object): this is NodePath<t.Pureish>;
768 isDeclaration(opts?: object): this is NodePath<t.Declaration>;
769 isLVal(opts?: object): this is NodePath<t.LVal>;
770 isLiteral(opts?: object): this is NodePath<t.Literal>;
771 isImmutable(opts?: object): this is NodePath<t.Immutable>;
772 isUserWhitespacable(opts?: object): this is NodePath<t.UserWhitespacable>;
773 isMethod(opts?: object): this is NodePath<t.Method>;
774 isObjectMember(opts?: object): this is NodePath<t.ObjectMember>;
775 isProperty(opts?: object): this is NodePath<t.Property>;
776 isUnaryLike(opts?: object): this is NodePath<t.UnaryLike>;
777 isPattern(opts?: object): this is NodePath<t.Pattern>;
778 isClass(opts?: object): this is NodePath<t.Class>;
779 isModuleDeclaration(opts?: object): this is NodePath<t.ModuleDeclaration>;
780 isExportDeclaration(opts?: object): this is NodePath<t.ExportDeclaration>;
781 isModuleSpecifier(opts?: object): this is NodePath<t.ModuleSpecifier>;
782 isFlow(opts?: object): this is NodePath<t.Flow>;
783 isFlowBaseAnnotation(opts?: object): this is NodePath<t.FlowBaseAnnotation>;
784 isFlowDeclaration(opts?: object): this is NodePath<t.FlowDeclaration>;
785 isJSX(opts?: object): this is NodePath<t.JSX>;
786 isNumberLiteral(opts?: object): this is NodePath<t.NumericLiteral>;
787 isRegexLiteral(opts?: object): this is NodePath<t.RegExpLiteral>;
788 isReferencedIdentifier(opts?: object): this is NodePath<t.Identifier | t.JSXIdentifier>;
789 isReferencedMemberExpression(opts?: object): this is NodePath<t.MemberExpression>;
790 isBindingIdentifier(opts?: object): this is NodePath<t.Identifier>;
791 isScope(opts?: object): this is NodePath<t.Scopable>;
792 isReferenced(opts?: object): boolean;
793 isBlockScoped(opts?: object): this is NodePath<t.FunctionDeclaration | t.ClassDeclaration | t.VariableDeclaration>;
794 isVar(opts?: object): this is NodePath<t.VariableDeclaration>;
795 isUser(opts?: object): boolean;
796 isGenerated(opts?: object): boolean;
797 isPure(opts?: object): boolean;
798
799 // ------------------------- assertXXX -------------------------
800 assertArrayExpression(opts?: object): void;
801 assertAssignmentExpression(opts?: object): void;
802 assertBinaryExpression(opts?: object): void;
803 assertDirective(opts?: object): void;
804 assertDirectiveLiteral(opts?: object): void;
805 assertBlockStatement(opts?: object): void;
806 assertBreakStatement(opts?: object): void;
807 assertCallExpression(opts?: object): void;
808 assertCatchClause(opts?: object): void;
809 assertConditionalExpression(opts?: object): void;
810 assertContinueStatement(opts?: object): void;
811 assertDebuggerStatement(opts?: object): void;
812 assertDoWhileStatement(opts?: object): void;
813 assertEmptyStatement(opts?: object): void;
814 assertExpressionStatement(opts?: object): void;
815 assertFile(opts?: object): void;
816 assertForInStatement(opts?: object): void;
817 assertForStatement(opts?: object): void;
818 assertFunctionDeclaration(opts?: object): void;
819 assertFunctionExpression(opts?: object): void;
820 assertIdentifier(opts?: object): void;
821 assertIfStatement(opts?: object): void;
822 assertLabeledStatement(opts?: object): void;
823 assertStringLiteral(opts?: object): void;
824 assertNumericLiteral(opts?: object): void;
825 assertNullLiteral(opts?: object): void;
826 assertBooleanLiteral(opts?: object): void;
827 assertRegExpLiteral(opts?: object): void;
828 assertLogicalExpression(opts?: object): void;
829 assertMemberExpression(opts?: object): void;
830 assertNewExpression(opts?: object): void;
831 assertProgram(opts?: object): void;
832 assertObjectExpression(opts?: object): void;
833 assertObjectMethod(opts?: object): void;
834 assertObjectProperty(opts?: object): void;
835 assertRestElement(opts?: object): void;
836 assertReturnStatement(opts?: object): void;
837 assertSequenceExpression(opts?: object): void;
838 assertSwitchCase(opts?: object): void;
839 assertSwitchStatement(opts?: object): void;
840 assertThisExpression(opts?: object): void;
841 assertThrowStatement(opts?: object): void;
842 assertTryStatement(opts?: object): void;
843 assertUnaryExpression(opts?: object): void;
844 assertUpdateExpression(opts?: object): void;
845 assertVariableDeclaration(opts?: object): void;
846 assertVariableDeclarator(opts?: object): void;
847 assertWhileStatement(opts?: object): void;
848 assertWithStatement(opts?: object): void;
849 assertAssignmentPattern(opts?: object): void;
850 assertArrayPattern(opts?: object): void;
851 assertArrowFunctionExpression(opts?: object): void;
852 assertClassBody(opts?: object): void;
853 assertClassDeclaration(opts?: object): void;
854 assertClassExpression(opts?: object): void;
855 assertExportAllDeclaration(opts?: object): void;
856 assertExportDefaultDeclaration(opts?: object): void;
857 assertExportNamedDeclaration(opts?: object): void;
858 assertExportSpecifier(opts?: object): void;
859 assertForOfStatement(opts?: object): void;
860 assertImportDeclaration(opts?: object): void;
861 assertImportDefaultSpecifier(opts?: object): void;
862 assertImportNamespaceSpecifier(opts?: object): void;
863 assertImportSpecifier(opts?: object): void;
864 assertMetaProperty(opts?: object): void;
865 assertClassMethod(opts?: object): void;
866 assertObjectPattern(opts?: object): void;
867 assertSpreadElement(opts?: object): void;
868 assertSuper(opts?: object): void;
869 assertTaggedTemplateExpression(opts?: object): void;
870 assertTemplateElement(opts?: object): void;
871 assertTemplateLiteral(opts?: object): void;
872 assertYieldExpression(opts?: object): void;
873 assertAnyTypeAnnotation(opts?: object): void;
874 assertArrayTypeAnnotation(opts?: object): void;
875 assertBooleanTypeAnnotation(opts?: object): void;
876 assertBooleanLiteralTypeAnnotation(opts?: object): void;
877 assertNullLiteralTypeAnnotation(opts?: object): void;
878 assertClassImplements(opts?: object): void;
879 assertClassProperty(opts?: object): void;
880 assertDeclareClass(opts?: object): void;
881 assertDeclareFunction(opts?: object): void;
882 assertDeclareInterface(opts?: object): void;
883 assertDeclareModule(opts?: object): void;
884 assertDeclareTypeAlias(opts?: object): void;
885 assertDeclareVariable(opts?: object): void;
886 assertExistentialTypeParam(opts?: object): void;
887 assertFunctionTypeAnnotation(opts?: object): void;
888 assertFunctionTypeParam(opts?: object): void;
889 assertGenericTypeAnnotation(opts?: object): void;
890 assertInterfaceExtends(opts?: object): void;
891 assertInterfaceDeclaration(opts?: object): void;
892 assertIntersectionTypeAnnotation(opts?: object): void;
893 assertMixedTypeAnnotation(opts?: object): void;
894 assertNullableTypeAnnotation(opts?: object): void;
895 assertNumericLiteralTypeAnnotation(opts?: object): void;
896 assertNumberTypeAnnotation(opts?: object): void;
897 assertStringLiteralTypeAnnotation(opts?: object): void;
898 assertStringTypeAnnotation(opts?: object): void;
899 assertThisTypeAnnotation(opts?: object): void;
900 assertTupleTypeAnnotation(opts?: object): void;
901 assertTypeofTypeAnnotation(opts?: object): void;
902 assertTypeAlias(opts?: object): void;
903 assertTypeAnnotation(opts?: object): void;
904 assertTypeCastExpression(opts?: object): void;
905 assertTypeParameterDeclaration(opts?: object): void;
906 assertTypeParameterInstantiation(opts?: object): void;
907 assertObjectTypeAnnotation(opts?: object): void;
908 assertObjectTypeCallProperty(opts?: object): void;
909 assertObjectTypeIndexer(opts?: object): void;
910 assertObjectTypeProperty(opts?: object): void;
911 assertQualifiedTypeIdentifier(opts?: object): void;
912 assertUnionTypeAnnotation(opts?: object): void;
913 assertVoidTypeAnnotation(opts?: object): void;
914 assertJSXAttribute(opts?: object): void;
915 assertJSXClosingElement(opts?: object): void;
916 assertJSXElement(opts?: object): void;
917 assertJSXEmptyExpression(opts?: object): void;
918 assertJSXExpressionContainer(opts?: object): void;
919 assertJSXIdentifier(opts?: object): void;
920 assertJSXMemberExpression(opts?: object): void;
921 assertJSXNamespacedName(opts?: object): void;
922 assertJSXOpeningElement(opts?: object): void;
923 assertJSXSpreadAttribute(opts?: object): void;
924 assertJSXText(opts?: object): void;
925 assertNoop(opts?: object): void;
926 assertParenthesizedExpression(opts?: object): void;
927 assertAwaitExpression(opts?: object): void;
928 assertBindExpression(opts?: object): void;
929 assertDecorator(opts?: object): void;
930 assertDoExpression(opts?: object): void;
931 assertExportDefaultSpecifier(opts?: object): void;
932 assertExportNamespaceSpecifier(opts?: object): void;
933 assertRestProperty(opts?: object): void;
934 assertSpreadProperty(opts?: object): void;
935 assertExpression(opts?: object): void;
936 assertBinary(opts?: object): void;
937 assertScopable(opts?: object): void;
938 assertBlockParent(opts?: object): void;
939 assertBlock(opts?: object): void;
940 assertStatement(opts?: object): void;
941 assertTerminatorless(opts?: object): void;
942 assertCompletionStatement(opts?: object): void;
943 assertConditional(opts?: object): void;
944 assertLoop(opts?: object): void;
945 assertWhile(opts?: object): void;
946 assertExpressionWrapper(opts?: object): void;
947 assertFor(opts?: object): void;
948 assertForXStatement(opts?: object): void;
949 assertFunction(opts?: object): void;
950 assertFunctionParent(opts?: object): void;
951 assertPureish(opts?: object): void;
952 assertDeclaration(opts?: object): void;
953 assertLVal(opts?: object): void;
954 assertLiteral(opts?: object): void;
955 assertImmutable(opts?: object): void;
956 assertUserWhitespacable(opts?: object): void;
957 assertMethod(opts?: object): void;
958 assertObjectMember(opts?: object): void;
959 assertProperty(opts?: object): void;
960 assertUnaryLike(opts?: object): void;
961 assertPattern(opts?: object): void;
962 assertClass(opts?: object): void;
963 assertModuleDeclaration(opts?: object): void;
964 assertExportDeclaration(opts?: object): void;
965 assertModuleSpecifier(opts?: object): void;
966 assertFlow(opts?: object): void;
967 assertFlowBaseAnnotation(opts?: object): void;
968 assertFlowDeclaration(opts?: object): void;
969 assertJSX(opts?: object): void;
970 assertNumberLiteral(opts?: object): void;
971 assertRegexLiteral(opts?: object): void;
972}
973
974export class Hub {
975 constructor(file: any, options: any);
976 file: any;
977 options: any;
978}
979
980export interface TraversalContext {
981 parentPath: NodePath;
982 scope: Scope;
983 state: any;
984 opts: any;
985}
986
\No newline at end of file