UNPKG

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