1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import * as t from 'babel-types';
|
10 | export type Node = t.Node;
|
11 |
|
12 | export default function traverse<S>(parent: Node | Node[], opts: TraverseOptions<S>, scope: Scope, state: S, parentPath?: NodePath): void;
|
13 | export default function traverse(parent: Node | Node[], opts: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath): void;
|
14 |
|
15 | export interface TraverseOptions<S = Node> extends Visitor<S> {
|
16 | scope?: Scope | undefined;
|
17 | noScope?: boolean | undefined;
|
18 | }
|
19 |
|
20 | export 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 |
|
30 | traverse<S>(node: Node | Node[], opts: TraverseOptions<S>, state: S): void;
|
31 | traverse(node: Node | Node[], opts?: TraverseOptions, state?: any): void;
|
32 |
|
33 |
|
34 | generateDeclaredUidIdentifier(name?: string): t.Identifier;
|
35 |
|
36 |
|
37 | generateUidIdentifier(name?: string): t.Identifier;
|
38 |
|
39 |
|
40 | generateUid(name?: string): string;
|
41 |
|
42 |
|
43 | generateUidIdentifierBasedOnNode(parent: Node, defaultName?: string): t.Identifier;
|
44 |
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | isStatic(node: Node): boolean;
|
55 |
|
56 |
|
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 |
|
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 |
|
119 | moveBindingTo(name: string, scope: Scope): void;
|
120 |
|
121 | removeOwnBinding(name: string): void;
|
122 |
|
123 | removeBinding(name: string): void;
|
124 | }
|
125 |
|
126 | export 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
|
144 | export interface Visitor<S = Node> extends VisitNodeObject<Node> {
|
145 | ArrayExpression?: VisitNode<S, t.ArrayExpression> | undefined;
|
146 | AssignmentExpression?: VisitNode<S, t.AssignmentExpression> | undefined;
|
147 | LVal?: VisitNode<S, t.LVal> | undefined;
|
148 | Expression?: VisitNode<S, t.Expression> | undefined;
|
149 | BinaryExpression?: VisitNode<S, t.BinaryExpression> | undefined;
|
150 | Directive?: VisitNode<S, t.Directive> | undefined;
|
151 | DirectiveLiteral?: VisitNode<S, t.DirectiveLiteral> | undefined;
|
152 | BlockStatement?: VisitNode<S, t.BlockStatement> | undefined;
|
153 | BreakStatement?: VisitNode<S, t.BreakStatement> | undefined;
|
154 | Identifier?: VisitNode<S, t.Identifier> | undefined;
|
155 | CallExpression?: VisitNode<S, t.CallExpression> | undefined;
|
156 | CatchClause?: VisitNode<S, t.CatchClause> | undefined;
|
157 | ConditionalExpression?: VisitNode<S, t.ConditionalExpression> | undefined;
|
158 | ContinueStatement?: VisitNode<S, t.ContinueStatement> | undefined;
|
159 | DebuggerStatement?: VisitNode<S, t.DebuggerStatement> | undefined;
|
160 | DoWhileStatement?: VisitNode<S, t.DoWhileStatement> | undefined;
|
161 | Statement?: VisitNode<S, t.Statement> | undefined;
|
162 | EmptyStatement?: VisitNode<S, t.EmptyStatement> | undefined;
|
163 | ExpressionStatement?: VisitNode<S, t.ExpressionStatement> | undefined;
|
164 | File?: VisitNode<S, t.File> | undefined;
|
165 | Program?: VisitNode<S, t.Program> | undefined;
|
166 | ForInStatement?: VisitNode<S, t.ForInStatement> | undefined;
|
167 | VariableDeclaration?: VisitNode<S, t.VariableDeclaration> | undefined;
|
168 | ForStatement?: VisitNode<S, t.ForStatement> | undefined;
|
169 | FunctionDeclaration?: VisitNode<S, t.FunctionDeclaration> | undefined;
|
170 | FunctionExpression?: VisitNode<S, t.FunctionExpression> | undefined;
|
171 | IfStatement?: VisitNode<S, t.IfStatement> | undefined;
|
172 | LabeledStatement?: VisitNode<S, t.LabeledStatement> | undefined;
|
173 | StringLiteral?: VisitNode<S, t.StringLiteral> | undefined;
|
174 | NumericLiteral?: VisitNode<S, t.NumericLiteral> | undefined;
|
175 | NullLiteral?: VisitNode<S, t.NullLiteral> | undefined;
|
176 | BooleanLiteral?: VisitNode<S, t.BooleanLiteral> | undefined;
|
177 | RegExpLiteral?: VisitNode<S, t.RegExpLiteral> | undefined;
|
178 | LogicalExpression?: VisitNode<S, t.LogicalExpression> | undefined;
|
179 | MemberExpression?: VisitNode<S, t.MemberExpression> | undefined;
|
180 | NewExpression?: VisitNode<S, t.NewExpression> | undefined;
|
181 | ObjectExpression?: VisitNode<S, t.ObjectExpression> | undefined;
|
182 | ObjectMethod?: VisitNode<S, t.ObjectMethod> | undefined;
|
183 | ObjectProperty?: VisitNode<S, t.ObjectProperty> | undefined;
|
184 | RestElement?: VisitNode<S, t.RestElement> | undefined;
|
185 | ReturnStatement?: VisitNode<S, t.ReturnStatement> | undefined;
|
186 | SequenceExpression?: VisitNode<S, t.SequenceExpression> | undefined;
|
187 | SwitchCase?: VisitNode<S, t.SwitchCase> | undefined;
|
188 | SwitchStatement?: VisitNode<S, t.SwitchStatement> | undefined;
|
189 | ThisExpression?: VisitNode<S, t.ThisExpression> | undefined;
|
190 | ThrowStatement?: VisitNode<S, t.ThrowStatement> | undefined;
|
191 | TryStatement?: VisitNode<S, t.TryStatement> | undefined;
|
192 | UnaryExpression?: VisitNode<S, t.UnaryExpression> | undefined;
|
193 | UpdateExpression?: VisitNode<S, t.UpdateExpression> | undefined;
|
194 | VariableDeclarator?: VisitNode<S, t.VariableDeclarator> | undefined;
|
195 | WhileStatement?: VisitNode<S, t.WhileStatement> | undefined;
|
196 | WithStatement?: VisitNode<S, t.WithStatement> | undefined;
|
197 | AssignmentPattern?: VisitNode<S, t.AssignmentPattern> | undefined;
|
198 | ArrayPattern?: VisitNode<S, t.ArrayPattern> | undefined;
|
199 | ArrowFunctionExpression?: VisitNode<S, t.ArrowFunctionExpression> | undefined;
|
200 | ClassBody?: VisitNode<S, t.ClassBody> | undefined;
|
201 | ClassDeclaration?: VisitNode<S, t.ClassDeclaration> | undefined;
|
202 | ClassExpression?: VisitNode<S, t.ClassExpression> | undefined;
|
203 | ExportAllDeclaration?: VisitNode<S, t.ExportAllDeclaration> | undefined;
|
204 | ExportDefaultDeclaration?: VisitNode<S, t.ExportDefaultDeclaration> | undefined;
|
205 | ExportNamedDeclaration?: VisitNode<S, t.ExportNamedDeclaration> | undefined;
|
206 | Declaration?: VisitNode<S, t.Declaration> | undefined;
|
207 | ExportSpecifier?: VisitNode<S, t.ExportSpecifier> | undefined;
|
208 | ForOfStatement?: VisitNode<S, t.ForOfStatement> | undefined;
|
209 | ImportDeclaration?: VisitNode<S, t.ImportDeclaration> | undefined;
|
210 | ImportDefaultSpecifier?: VisitNode<S, t.ImportDefaultSpecifier> | undefined;
|
211 | ImportNamespaceSpecifier?: VisitNode<S, t.ImportNamespaceSpecifier> | undefined;
|
212 | ImportSpecifier?: VisitNode<S, t.ImportSpecifier> | undefined;
|
213 | MetaProperty?: VisitNode<S, t.MetaProperty> | undefined;
|
214 | ClassMethod?: VisitNode<S, t.ClassMethod> | undefined;
|
215 | ObjectPattern?: VisitNode<S, t.ObjectPattern> | undefined;
|
216 | SpreadElement?: VisitNode<S, t.SpreadElement> | undefined;
|
217 | Super?: VisitNode<S, t.Super> | undefined;
|
218 | TaggedTemplateExpression?: VisitNode<S, t.TaggedTemplateExpression> | undefined;
|
219 | TemplateLiteral?: VisitNode<S, t.TemplateLiteral> | undefined;
|
220 | TemplateElement?: VisitNode<S, t.TemplateElement> | undefined;
|
221 | YieldExpression?: VisitNode<S, t.YieldExpression> | undefined;
|
222 | AnyTypeAnnotation?: VisitNode<S, t.AnyTypeAnnotation> | undefined;
|
223 | ArrayTypeAnnotation?: VisitNode<S, t.ArrayTypeAnnotation> | undefined;
|
224 | BooleanTypeAnnotation?: VisitNode<S, t.BooleanTypeAnnotation> | undefined;
|
225 | BooleanLiteralTypeAnnotation?: VisitNode<S, t.BooleanLiteralTypeAnnotation> | undefined;
|
226 | NullLiteralTypeAnnotation?: VisitNode<S, t.NullLiteralTypeAnnotation> | undefined;
|
227 | ClassImplements?: VisitNode<S, t.ClassImplements> | undefined;
|
228 | ClassProperty?: VisitNode<S, t.ClassProperty> | undefined;
|
229 | DeclareClass?: VisitNode<S, t.DeclareClass> | undefined;
|
230 | DeclareFunction?: VisitNode<S, t.DeclareFunction> | undefined;
|
231 | DeclareInterface?: VisitNode<S, t.DeclareInterface> | undefined;
|
232 | DeclareModule?: VisitNode<S, t.DeclareModule> | undefined;
|
233 | DeclareTypeAlias?: VisitNode<S, t.DeclareTypeAlias> | undefined;
|
234 | DeclareVariable?: VisitNode<S, t.DeclareVariable> | undefined;
|
235 | ExistentialTypeParam?: VisitNode<S, t.ExistentialTypeParam> | undefined;
|
236 | FunctionTypeAnnotation?: VisitNode<S, t.FunctionTypeAnnotation> | undefined;
|
237 | FunctionTypeParam?: VisitNode<S, t.FunctionTypeParam> | undefined;
|
238 | GenericTypeAnnotation?: VisitNode<S, t.GenericTypeAnnotation> | undefined;
|
239 | InterfaceExtends?: VisitNode<S, t.InterfaceExtends> | undefined;
|
240 | InterfaceDeclaration?: VisitNode<S, t.InterfaceDeclaration> | undefined;
|
241 | IntersectionTypeAnnotation?: VisitNode<S, t.IntersectionTypeAnnotation> | undefined;
|
242 | MixedTypeAnnotation?: VisitNode<S, t.MixedTypeAnnotation> | undefined;
|
243 | NullableTypeAnnotation?: VisitNode<S, t.NullableTypeAnnotation> | undefined;
|
244 | NumericLiteralTypeAnnotation?: VisitNode<S, t.NumericLiteralTypeAnnotation> | undefined;
|
245 | NumberTypeAnnotation?: VisitNode<S, t.NumberTypeAnnotation> | undefined;
|
246 | StringLiteralTypeAnnotation?: VisitNode<S, t.StringLiteralTypeAnnotation> | undefined;
|
247 | StringTypeAnnotation?: VisitNode<S, t.StringTypeAnnotation> | undefined;
|
248 | ThisTypeAnnotation?: VisitNode<S, t.ThisTypeAnnotation> | undefined;
|
249 | TupleTypeAnnotation?: VisitNode<S, t.TupleTypeAnnotation> | undefined;
|
250 | TypeofTypeAnnotation?: VisitNode<S, t.TypeofTypeAnnotation> | undefined;
|
251 | TypeAlias?: VisitNode<S, t.TypeAlias> | undefined;
|
252 | TypeAnnotation?: VisitNode<S, t.TypeAnnotation> | undefined;
|
253 | TypeCastExpression?: VisitNode<S, t.TypeCastExpression> | undefined;
|
254 | TypeParameterDeclaration?: VisitNode<S, t.TypeParameterDeclaration> | undefined;
|
255 | TypeParameterInstantiation?: VisitNode<S, t.TypeParameterInstantiation> | undefined;
|
256 | ObjectTypeAnnotation?: VisitNode<S, t.ObjectTypeAnnotation> | undefined;
|
257 | ObjectTypeCallProperty?: VisitNode<S, t.ObjectTypeCallProperty> | undefined;
|
258 | ObjectTypeIndexer?: VisitNode<S, t.ObjectTypeIndexer> | undefined;
|
259 | ObjectTypeProperty?: VisitNode<S, t.ObjectTypeProperty> | undefined;
|
260 | QualifiedTypeIdentifier?: VisitNode<S, t.QualifiedTypeIdentifier> | undefined;
|
261 | UnionTypeAnnotation?: VisitNode<S, t.UnionTypeAnnotation> | undefined;
|
262 | VoidTypeAnnotation?: VisitNode<S, t.VoidTypeAnnotation> | undefined;
|
263 | JSXAttribute?: VisitNode<S, t.JSXAttribute> | undefined;
|
264 | JSXIdentifier?: VisitNode<S, t.JSXIdentifier> | undefined;
|
265 | JSXNamespacedName?: VisitNode<S, t.JSXNamespacedName> | undefined;
|
266 | JSXElement?: VisitNode<S, t.JSXElement> | undefined;
|
267 | JSXExpressionContainer?: VisitNode<S, t.JSXExpressionContainer> | undefined;
|
268 | JSXClosingElement?: VisitNode<S, t.JSXClosingElement> | undefined;
|
269 | JSXMemberExpression?: VisitNode<S, t.JSXMemberExpression> | undefined;
|
270 | JSXOpeningElement?: VisitNode<S, t.JSXOpeningElement> | undefined;
|
271 | JSXEmptyExpression?: VisitNode<S, t.JSXEmptyExpression> | undefined;
|
272 | JSXSpreadAttribute?: VisitNode<S, t.JSXSpreadAttribute> | undefined;
|
273 | JSXText?: VisitNode<S, t.JSXText> | undefined;
|
274 | Noop?: VisitNode<S, t.Noop> | undefined;
|
275 | ParenthesizedExpression?: VisitNode<S, t.ParenthesizedExpression> | undefined;
|
276 | AwaitExpression?: VisitNode<S, t.AwaitExpression> | undefined;
|
277 | BindExpression?: VisitNode<S, t.BindExpression> | undefined;
|
278 | Decorator?: VisitNode<S, t.Decorator> | undefined;
|
279 | DoExpression?: VisitNode<S, t.DoExpression> | undefined;
|
280 | ExportDefaultSpecifier?: VisitNode<S, t.ExportDefaultSpecifier> | undefined;
|
281 | ExportNamespaceSpecifier?: VisitNode<S, t.ExportNamespaceSpecifier> | undefined;
|
282 | RestProperty?: VisitNode<S, t.RestProperty> | undefined;
|
283 | SpreadProperty?: VisitNode<S, t.SpreadProperty> | undefined;
|
284 | Binary?: VisitNode<S, t.Binary> | undefined;
|
285 | Scopable?: VisitNode<S, t.Scopable> | undefined;
|
286 | BlockParent?: VisitNode<S, t.BlockParent> | undefined;
|
287 | Block?: VisitNode<S, t.Block> | undefined;
|
288 | Terminatorless?: VisitNode<S, t.Terminatorless> | undefined;
|
289 | CompletionStatement?: VisitNode<S, t.CompletionStatement> | undefined;
|
290 | Conditional?: VisitNode<S, t.Conditional> | undefined;
|
291 | Loop?: VisitNode<S, t.Loop> | undefined;
|
292 | While?: VisitNode<S, t.While> | undefined;
|
293 | ExpressionWrapper?: VisitNode<S, t.ExpressionWrapper> | undefined;
|
294 | For?: VisitNode<S, t.For> | undefined;
|
295 | ForXStatement?: VisitNode<S, t.ForXStatement> | undefined;
|
296 | Function?: VisitNode<S, t.Function> | undefined;
|
297 | FunctionParent?: VisitNode<S, t.FunctionParent> | undefined;
|
298 | Pureish?: VisitNode<S, t.Pureish> | undefined;
|
299 | Literal?: VisitNode<S, t.Literal> | undefined;
|
300 | Immutable?: VisitNode<S, t.Immutable> | undefined;
|
301 | UserWhitespacable?: VisitNode<S, t.UserWhitespacable> | undefined;
|
302 | Method?: VisitNode<S, t.Method> | undefined;
|
303 | ObjectMember?: VisitNode<S, t.ObjectMember> | undefined;
|
304 | Property?: VisitNode<S, t.Property> | undefined;
|
305 | UnaryLike?: VisitNode<S, t.UnaryLike> | undefined;
|
306 | Pattern?: VisitNode<S, t.Pattern> | undefined;
|
307 | Class?: VisitNode<S, t.Class> | undefined;
|
308 | ModuleDeclaration?: VisitNode<S, t.ModuleDeclaration> | undefined;
|
309 | ExportDeclaration?: VisitNode<S, t.ExportDeclaration> | undefined;
|
310 | ModuleSpecifier?: VisitNode<S, t.ModuleSpecifier> | undefined;
|
311 | Flow?: VisitNode<S, t.Flow> | undefined;
|
312 | FlowBaseAnnotation?: VisitNode<S, t.FlowBaseAnnotation> | undefined;
|
313 | FlowDeclaration?: VisitNode<S, t.FlowDeclaration> | undefined;
|
314 | JSX?: VisitNode<S, t.JSX> | undefined;
|
315 | Scope?: VisitNode<S, t.Scopable> | undefined;
|
316 | }
|
317 |
|
318 | export type VisitNode<T, P> = VisitNodeFunction<T, P> | VisitNodeObject<T>;
|
319 |
|
320 | export type VisitNodeFunction<T, P> = (this: T, path: NodePath<P>, state: any) => void;
|
321 |
|
322 | export interface VisitNodeObject<T> {
|
323 | enter?(path: NodePath<T>, state: any): void;
|
324 | exit?(path: NodePath<T>, state: any): void;
|
325 | }
|
326 |
|
327 | export 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 | getNextSibling(): NodePath;
|
594 | getPrevSibling(): NodePath;
|
595 | getAllPrevSiblings(): NodePath[];
|
596 | getAllNextSiblings(): NodePath[];
|
597 |
|
598 | get<K extends keyof T>(key: K, context?: boolean | TraversalContext):
|
599 | T[K] extends Array<Node | null | undefined> ? Array<NodePath<T[K][number]>> :
|
600 | T[K] extends Node | null | undefined ? NodePath<T[K]> :
|
601 | never;
|
602 | get(key: string, context?: boolean | TraversalContext): NodePath | NodePath[];
|
603 |
|
604 | getBindingIdentifiers(duplicates?: boolean): Node[];
|
605 |
|
606 | getOuterBindingIdentifiers(duplicates?: boolean): Node[];
|
607 |
|
608 | // ------------------------- comments -------------------------
|
609 | /** Share comments amongst siblings. */
|
610 | shareCommentsWithSiblings(): void;
|
611 |
|
612 | addComment(type: string, content: string, line?: boolean): void;
|
613 |
|
614 | /** Give node `comments` of the specified `type`. */
|
615 | addComments(type: string, comments: any[]): void;
|
616 |
|
617 | // ------------------------- isXXX -------------------------
|
618 | isArrayExpression(opts?: object): this is NodePath<t.ArrayExpression> ;
|
619 | isAssignmentExpression(opts?: object): this is NodePath<t.AssignmentExpression>;
|
620 | isBinaryExpression(opts?: object): this is NodePath<t.BinaryExpression>;
|
621 | isDirective(opts?: object): this is NodePath<t.Directive>;
|
622 | isDirectiveLiteral(opts?: object): this is NodePath<t.DirectiveLiteral>;
|
623 | isBlockStatement(opts?: object): this is NodePath<t.BlockStatement>;
|
624 | isBreakStatement(opts?: object): this is NodePath<t.BreakStatement>;
|
625 | isCallExpression(opts?: object): this is NodePath<t.CallExpression>;
|
626 | isCatchClause(opts?: object): this is NodePath<t.CatchClause>;
|
627 | isConditionalExpression(opts?: object): this is NodePath<t.ConditionalExpression>;
|
628 | isContinueStatement(opts?: object): this is NodePath<t.ContinueStatement>;
|
629 | isDebuggerStatement(opts?: object): this is NodePath<t.DebuggerStatement>;
|
630 | isDoWhileStatement(opts?: object): this is NodePath<t.DoWhileStatement>;
|
631 | isEmptyStatement(opts?: object): this is NodePath<t.EmptyStatement>;
|
632 | isExpressionStatement(opts?: object): this is NodePath<t.ExpressionStatement>;
|
633 | isFile(opts?: object): this is NodePath<t.File>;
|
634 | isForInStatement(opts?: object): this is NodePath<t.ForInStatement>;
|
635 | isForStatement(opts?: object): this is NodePath<t.ForStatement>;
|
636 | isFunctionDeclaration(opts?: object): this is NodePath<t.FunctionDeclaration>;
|
637 | isFunctionExpression(opts?: object): this is NodePath<t.FunctionExpression>;
|
638 | isIdentifier(opts?: object): this is NodePath<t.Identifier>;
|
639 | isIfStatement(opts?: object): this is NodePath<t.IfStatement>;
|
640 | isLabeledStatement(opts?: object): this is NodePath<t.LabeledStatement>;
|
641 | isStringLiteral(opts?: object): this is NodePath<t.StringLiteral>;
|
642 | isNumericLiteral(opts?: object): this is NodePath<t.NumericLiteral>;
|
643 | isNullLiteral(opts?: object): this is NodePath<t.NullLiteral>;
|
644 | isBooleanLiteral(opts?: object): this is NodePath<t.BooleanLiteral>;
|
645 | isRegExpLiteral(opts?: object): this is NodePath<t.RegExpLiteral>;
|
646 | isLogicalExpression(opts?: object): this is NodePath<t.LogicalExpression>;
|
647 | isMemberExpression(opts?: object): this is NodePath<t.MemberExpression>;
|
648 | isNewExpression(opts?: object): this is NodePath<t.NewExpression>;
|
649 | isProgram(opts?: object): this is NodePath<t.Program>;
|
650 | isObjectExpression(opts?: object): this is NodePath<t.ObjectExpression>;
|
651 | isObjectMethod(opts?: object): this is NodePath<t.ObjectMethod>;
|
652 | isObjectProperty(opts?: object): this is NodePath<t.ObjectProperty>;
|
653 | isRestElement(opts?: object): this is NodePath<t.RestElement>;
|
654 | isReturnStatement(opts?: object): this is NodePath<t.ReturnStatement>;
|
655 | isSequenceExpression(opts?: object): this is NodePath<t.SequenceExpression>;
|
656 | isSwitchCase(opts?: object): this is NodePath<t.SwitchCase>;
|
657 | isSwitchStatement(opts?: object): this is NodePath<t.SwitchStatement>;
|
658 | isThisExpression(opts?: object): this is NodePath<t.ThisExpression>;
|
659 | isThrowStatement(opts?: object): this is NodePath<t.ThrowStatement>;
|
660 | isTryStatement(opts?: object): this is NodePath<t.TryStatement>;
|
661 | isUnaryExpression(opts?: object): this is NodePath<t.UnaryExpression>;
|
662 | isUpdateExpression(opts?: object): this is NodePath<t.UpdateExpression>;
|
663 | isVariableDeclaration(opts?: object): this is NodePath<t.VariableDeclaration>;
|
664 | isVariableDeclarator(opts?: object): this is NodePath<t.VariableDeclarator>;
|
665 | isWhileStatement(opts?: object): this is NodePath<t.WhileStatement>;
|
666 | isWithStatement(opts?: object): this is NodePath<t.WithStatement>;
|
667 | isAssignmentPattern(opts?: object): this is NodePath<t.AssignmentPattern>;
|
668 | isArrayPattern(opts?: object): this is NodePath<t.ArrayPattern>;
|
669 | isArrowFunctionExpression(opts?: object): this is NodePath<t.ArrowFunctionExpression>;
|
670 | isClassBody(opts?: object): this is NodePath<t.ClassBody>;
|
671 | isClassDeclaration(opts?: object): this is NodePath<t.ClassDeclaration>;
|
672 | isClassExpression(opts?: object): this is NodePath<t.ClassExpression>;
|
673 | isExportAllDeclaration(opts?: object): this is NodePath<t.ExportAllDeclaration>;
|
674 | isExportDefaultDeclaration(opts?: object): this is NodePath<t.ExportDefaultDeclaration>;
|
675 | isExportNamedDeclaration(opts?: object): this is NodePath<t.ExportNamedDeclaration>;
|
676 | isExportSpecifier(opts?: object): this is NodePath<t.ExportSpecifier>;
|
677 | isForOfStatement(opts?: object): this is NodePath<t.ForOfStatement>;
|
678 | isImportDeclaration(opts?: object): this is NodePath<t.ImportDeclaration>;
|
679 | isImportDefaultSpecifier(opts?: object): this is NodePath<t.ImportDefaultSpecifier>;
|
680 | isImportNamespaceSpecifier(opts?: object): this is NodePath<t.ImportNamespaceSpecifier>;
|
681 | isImportSpecifier(opts?: object): this is NodePath<t.ImportSpecifier>;
|
682 | isMetaProperty(opts?: object): this is NodePath<t.MetaProperty>;
|
683 | isClassMethod(opts?: object): this is NodePath<t.ClassMethod>;
|
684 | isObjectPattern(opts?: object): this is NodePath<t.ObjectPattern>;
|
685 | isSpreadElement(opts?: object): this is NodePath<t.SpreadElement>;
|
686 | isSuper(opts?: object): this is NodePath<t.Super>;
|
687 | isTaggedTemplateExpression(opts?: object): this is NodePath<t.TaggedTemplateExpression>;
|
688 | isTemplateElement(opts?: object): this is NodePath<t.TemplateElement>;
|
689 | isTemplateLiteral(opts?: object): this is NodePath<t.TemplateLiteral>;
|
690 | isYieldExpression(opts?: object): this is NodePath<t.YieldExpression>;
|
691 | isAnyTypeAnnotation(opts?: object): this is NodePath<t.AnyTypeAnnotation>;
|
692 | isArrayTypeAnnotation(opts?: object): this is NodePath<t.ArrayTypeAnnotation>;
|
693 | isBooleanTypeAnnotation(opts?: object): this is NodePath<t.BooleanTypeAnnotation>;
|
694 | isBooleanLiteralTypeAnnotation(opts?: object): this is NodePath<t.BooleanLiteralTypeAnnotation>;
|
695 | isNullLiteralTypeAnnotation(opts?: object): this is NodePath<t.NullLiteralTypeAnnotation>;
|
696 | isClassImplements(opts?: object): this is NodePath<t.ClassImplements>;
|
697 | isClassProperty(opts?: object): this is NodePath<t.ClassProperty>;
|
698 | isDeclareClass(opts?: object): this is NodePath<t.DeclareClass>;
|
699 | isDeclareFunction(opts?: object): this is NodePath<t.DeclareFunction>;
|
700 | isDeclareInterface(opts?: object): this is NodePath<t.DeclareInterface>;
|
701 | isDeclareModule(opts?: object): this is NodePath<t.DeclareModule>;
|
702 | isDeclareTypeAlias(opts?: object): this is NodePath<t.DeclareTypeAlias>;
|
703 | isDeclareVariable(opts?: object): this is NodePath<t.DeclareVariable>;
|
704 | isExistentialTypeParam(opts?: object): this is NodePath<t.ExistentialTypeParam>;
|
705 | isFunctionTypeAnnotation(opts?: object): this is NodePath<t.FunctionTypeAnnotation>;
|
706 | isFunctionTypeParam(opts?: object): this is NodePath<t.FunctionTypeParam>;
|
707 | isGenericTypeAnnotation(opts?: object): this is NodePath<t.GenericTypeAnnotation>;
|
708 | isInterfaceExtends(opts?: object): this is NodePath<t.InterfaceExtends>;
|
709 | isInterfaceDeclaration(opts?: object): this is NodePath<t.InterfaceDeclaration>;
|
710 | isIntersectionTypeAnnotation(opts?: object): this is NodePath<t.IntersectionTypeAnnotation>;
|
711 | isMixedTypeAnnotation(opts?: object): this is NodePath<t.MixedTypeAnnotation>;
|
712 | isNullableTypeAnnotation(opts?: object): this is NodePath<t.NullableTypeAnnotation>;
|
713 | isNumericLiteralTypeAnnotation(opts?: object): this is NodePath<t.NumericLiteralTypeAnnotation>;
|
714 | isNumberTypeAnnotation(opts?: object): this is NodePath<t.NumberTypeAnnotation>;
|
715 | isStringLiteralTypeAnnotation(opts?: object): this is NodePath<t.StringLiteralTypeAnnotation>;
|
716 | isStringTypeAnnotation(opts?: object): this is NodePath<t.StringTypeAnnotation>;
|
717 | isThisTypeAnnotation(opts?: object): this is NodePath<t.ThisTypeAnnotation>;
|
718 | isTupleTypeAnnotation(opts?: object): this is NodePath<t.TupleTypeAnnotation>;
|
719 | isTypeofTypeAnnotation(opts?: object): this is NodePath<t.TypeofTypeAnnotation>;
|
720 | isTypeAlias(opts?: object): this is NodePath<t.TypeAlias>;
|
721 | isTypeAnnotation(opts?: object): this is NodePath<t.TypeAnnotation>;
|
722 | isTypeCastExpression(opts?: object): this is NodePath<t.TypeCastExpression>;
|
723 | isTypeParameterDeclaration(opts?: object): this is NodePath<t.TypeParameterDeclaration>;
|
724 | isTypeParameterInstantiation(opts?: object): this is NodePath<t.TypeParameterInstantiation>;
|
725 | isObjectTypeAnnotation(opts?: object): this is NodePath<t.ObjectTypeAnnotation>;
|
726 | isObjectTypeCallProperty(opts?: object): this is NodePath<t.ObjectTypeCallProperty>;
|
727 | isObjectTypeIndexer(opts?: object): this is NodePath<t.ObjectTypeIndexer>;
|
728 | isObjectTypeProperty(opts?: object): this is NodePath<t.ObjectTypeProperty>;
|
729 | isQualifiedTypeIdentifier(opts?: object): this is NodePath<t.QualifiedTypeIdentifier>;
|
730 | isUnionTypeAnnotation(opts?: object): this is NodePath<t.UnionTypeAnnotation>;
|
731 | isVoidTypeAnnotation(opts?: object): this is NodePath<t.VoidTypeAnnotation>;
|
732 | isJSXAttribute(opts?: object): this is NodePath<t.JSXAttribute>;
|
733 | isJSXClosingElement(opts?: object): this is NodePath<t.JSXClosingElement>;
|
734 | isJSXElement(opts?: object): this is NodePath<t.JSXElement>;
|
735 | isJSXEmptyExpression(opts?: object): this is NodePath<t.JSXEmptyExpression>;
|
736 | isJSXExpressionContainer(opts?: object): this is NodePath<t.JSXExpressionContainer>;
|
737 | isJSXIdentifier(opts?: object): this is NodePath<t.JSXIdentifier>;
|
738 | isJSXMemberExpression(opts?: object): this is NodePath<t.JSXMemberExpression>;
|
739 | isJSXNamespacedName(opts?: object): this is NodePath<t.JSXNamespacedName>;
|
740 | isJSXOpeningElement(opts?: object): this is NodePath<t.JSXOpeningElement>;
|
741 | isJSXSpreadAttribute(opts?: object): this is NodePath<t.JSXSpreadAttribute>;
|
742 | isJSXText(opts?: object): this is NodePath<t.JSXText>;
|
743 | isNoop(opts?: object): this is NodePath<t.Noop>;
|
744 | isParenthesizedExpression(opts?: object): this is NodePath<t.ParenthesizedExpression>;
|
745 | isAwaitExpression(opts?: object): this is NodePath<t.AwaitExpression>;
|
746 | isBindExpression(opts?: object): this is NodePath<t.BindExpression>;
|
747 | isDecorator(opts?: object): this is NodePath<t.Decorator>;
|
748 | isDoExpression(opts?: object): this is NodePath<t.DoExpression>;
|
749 | isExportDefaultSpecifier(opts?: object): this is NodePath<t.ExportDefaultSpecifier>;
|
750 | isExportNamespaceSpecifier(opts?: object): this is NodePath<t.ExportNamespaceSpecifier>;
|
751 | isRestProperty(opts?: object): this is NodePath<t.RestProperty>;
|
752 | isSpreadProperty(opts?: object): this is NodePath<t.SpreadProperty>;
|
753 | isExpression(opts?: object): this is NodePath<t.Expression>;
|
754 | isBinary(opts?: object): this is NodePath<t.Binary>;
|
755 | isScopable(opts?: object): this is NodePath<t.Scopable>;
|
756 | isBlockParent(opts?: object): this is NodePath<t.BlockParent>;
|
757 | isBlock(opts?: object): this is NodePath<t.Block>;
|
758 | isStatement(opts?: object): this is NodePath<t.Statement>;
|
759 | isTerminatorless(opts?: object): this is NodePath<t.Terminatorless>;
|
760 | isCompletionStatement(opts?: object): this is NodePath<t.CompletionStatement>;
|
761 | isConditional(opts?: object): this is NodePath<t.Conditional>;
|
762 | isLoop(opts?: object): this is NodePath<t.Loop>;
|
763 | isWhile(opts?: object): this is NodePath<t.While>;
|
764 | isExpressionWrapper(opts?: object): this is NodePath<t.ExpressionWrapper>;
|
765 | isFor(opts?: object): this is NodePath<t.For>;
|
766 | isForXStatement(opts?: object): this is NodePath<t.ForXStatement>;
|
767 | isFunction(opts?: object): this is NodePath<t.Function>;
|
768 | isFunctionParent(opts?: object): this is NodePath<t.FunctionParent>;
|
769 | isPureish(opts?: object): this is NodePath<t.Pureish>;
|
770 | isDeclaration(opts?: object): this is NodePath<t.Declaration>;
|
771 | isLVal(opts?: object): this is NodePath<t.LVal>;
|
772 | isLiteral(opts?: object): this is NodePath<t.Literal>;
|
773 | isImmutable(opts?: object): this is NodePath<t.Immutable>;
|
774 | isUserWhitespacable(opts?: object): this is NodePath<t.UserWhitespacable>;
|
775 | isMethod(opts?: object): this is NodePath<t.Method>;
|
776 | isObjectMember(opts?: object): this is NodePath<t.ObjectMember>;
|
777 | isProperty(opts?: object): this is NodePath<t.Property>;
|
778 | isUnaryLike(opts?: object): this is NodePath<t.UnaryLike>;
|
779 | isPattern(opts?: object): this is NodePath<t.Pattern>;
|
780 | isClass(opts?: object): this is NodePath<t.Class>;
|
781 | isModuleDeclaration(opts?: object): this is NodePath<t.ModuleDeclaration>;
|
782 | isExportDeclaration(opts?: object): this is NodePath<t.ExportDeclaration>;
|
783 | isModuleSpecifier(opts?: object): this is NodePath<t.ModuleSpecifier>;
|
784 | isFlow(opts?: object): this is NodePath<t.Flow>;
|
785 | isFlowBaseAnnotation(opts?: object): this is NodePath<t.FlowBaseAnnotation>;
|
786 | isFlowDeclaration(opts?: object): this is NodePath<t.FlowDeclaration>;
|
787 | isJSX(opts?: object): this is NodePath<t.JSX>;
|
788 | isNumberLiteral(opts?: object): this is NodePath<t.NumericLiteral>;
|
789 | isRegexLiteral(opts?: object): this is NodePath<t.RegExpLiteral>;
|
790 | isReferencedIdentifier(opts?: object): this is NodePath<t.Identifier | t.JSXIdentifier>;
|
791 | isReferencedMemberExpression(opts?: object): this is NodePath<t.MemberExpression>;
|
792 | isBindingIdentifier(opts?: object): this is NodePath<t.Identifier>;
|
793 | isScope(opts?: object): this is NodePath<t.Scopable>;
|
794 | isReferenced(opts?: object): boolean;
|
795 | isBlockScoped(opts?: object): this is NodePath<t.FunctionDeclaration | t.ClassDeclaration | t.VariableDeclaration>;
|
796 | isVar(opts?: object): this is NodePath<t.VariableDeclaration>;
|
797 | isUser(opts?: object): boolean;
|
798 | isGenerated(opts?: object): boolean;
|
799 | isPure(opts?: object): boolean;
|
800 |
|
801 | // ------------------------- assertXXX -------------------------
|
802 | assertArrayExpression(opts?: object): void;
|
803 | assertAssignmentExpression(opts?: object): void;
|
804 | assertBinaryExpression(opts?: object): void;
|
805 | assertDirective(opts?: object): void;
|
806 | assertDirectiveLiteral(opts?: object): void;
|
807 | assertBlockStatement(opts?: object): void;
|
808 | assertBreakStatement(opts?: object): void;
|
809 | assertCallExpression(opts?: object): void;
|
810 | assertCatchClause(opts?: object): void;
|
811 | assertConditionalExpression(opts?: object): void;
|
812 | assertContinueStatement(opts?: object): void;
|
813 | assertDebuggerStatement(opts?: object): void;
|
814 | assertDoWhileStatement(opts?: object): void;
|
815 | assertEmptyStatement(opts?: object): void;
|
816 | assertExpressionStatement(opts?: object): void;
|
817 | assertFile(opts?: object): void;
|
818 | assertForInStatement(opts?: object): void;
|
819 | assertForStatement(opts?: object): void;
|
820 | assertFunctionDeclaration(opts?: object): void;
|
821 | assertFunctionExpression(opts?: object): void;
|
822 | assertIdentifier(opts?: object): void;
|
823 | assertIfStatement(opts?: object): void;
|
824 | assertLabeledStatement(opts?: object): void;
|
825 | assertStringLiteral(opts?: object): void;
|
826 | assertNumericLiteral(opts?: object): void;
|
827 | assertNullLiteral(opts?: object): void;
|
828 | assertBooleanLiteral(opts?: object): void;
|
829 | assertRegExpLiteral(opts?: object): void;
|
830 | assertLogicalExpression(opts?: object): void;
|
831 | assertMemberExpression(opts?: object): void;
|
832 | assertNewExpression(opts?: object): void;
|
833 | assertProgram(opts?: object): void;
|
834 | assertObjectExpression(opts?: object): void;
|
835 | assertObjectMethod(opts?: object): void;
|
836 | assertObjectProperty(opts?: object): void;
|
837 | assertRestElement(opts?: object): void;
|
838 | assertReturnStatement(opts?: object): void;
|
839 | assertSequenceExpression(opts?: object): void;
|
840 | assertSwitchCase(opts?: object): void;
|
841 | assertSwitchStatement(opts?: object): void;
|
842 | assertThisExpression(opts?: object): void;
|
843 | assertThrowStatement(opts?: object): void;
|
844 | assertTryStatement(opts?: object): void;
|
845 | assertUnaryExpression(opts?: object): void;
|
846 | assertUpdateExpression(opts?: object): void;
|
847 | assertVariableDeclaration(opts?: object): void;
|
848 | assertVariableDeclarator(opts?: object): void;
|
849 | assertWhileStatement(opts?: object): void;
|
850 | assertWithStatement(opts?: object): void;
|
851 | assertAssignmentPattern(opts?: object): void;
|
852 | assertArrayPattern(opts?: object): void;
|
853 | assertArrowFunctionExpression(opts?: object): void;
|
854 | assertClassBody(opts?: object): void;
|
855 | assertClassDeclaration(opts?: object): void;
|
856 | assertClassExpression(opts?: object): void;
|
857 | assertExportAllDeclaration(opts?: object): void;
|
858 | assertExportDefaultDeclaration(opts?: object): void;
|
859 | assertExportNamedDeclaration(opts?: object): void;
|
860 | assertExportSpecifier(opts?: object): void;
|
861 | assertForOfStatement(opts?: object): void;
|
862 | assertImportDeclaration(opts?: object): void;
|
863 | assertImportDefaultSpecifier(opts?: object): void;
|
864 | assertImportNamespaceSpecifier(opts?: object): void;
|
865 | assertImportSpecifier(opts?: object): void;
|
866 | assertMetaProperty(opts?: object): void;
|
867 | assertClassMethod(opts?: object): void;
|
868 | assertObjectPattern(opts?: object): void;
|
869 | assertSpreadElement(opts?: object): void;
|
870 | assertSuper(opts?: object): void;
|
871 | assertTaggedTemplateExpression(opts?: object): void;
|
872 | assertTemplateElement(opts?: object): void;
|
873 | assertTemplateLiteral(opts?: object): void;
|
874 | assertYieldExpression(opts?: object): void;
|
875 | assertAnyTypeAnnotation(opts?: object): void;
|
876 | assertArrayTypeAnnotation(opts?: object): void;
|
877 | assertBooleanTypeAnnotation(opts?: object): void;
|
878 | assertBooleanLiteralTypeAnnotation(opts?: object): void;
|
879 | assertNullLiteralTypeAnnotation(opts?: object): void;
|
880 | assertClassImplements(opts?: object): void;
|
881 | assertClassProperty(opts?: object): void;
|
882 | assertDeclareClass(opts?: object): void;
|
883 | assertDeclareFunction(opts?: object): void;
|
884 | assertDeclareInterface(opts?: object): void;
|
885 | assertDeclareModule(opts?: object): void;
|
886 | assertDeclareTypeAlias(opts?: object): void;
|
887 | assertDeclareVariable(opts?: object): void;
|
888 | assertExistentialTypeParam(opts?: object): void;
|
889 | assertFunctionTypeAnnotation(opts?: object): void;
|
890 | assertFunctionTypeParam(opts?: object): void;
|
891 | assertGenericTypeAnnotation(opts?: object): void;
|
892 | assertInterfaceExtends(opts?: object): void;
|
893 | assertInterfaceDeclaration(opts?: object): void;
|
894 | assertIntersectionTypeAnnotation(opts?: object): void;
|
895 | assertMixedTypeAnnotation(opts?: object): void;
|
896 | assertNullableTypeAnnotation(opts?: object): void;
|
897 | assertNumericLiteralTypeAnnotation(opts?: object): void;
|
898 | assertNumberTypeAnnotation(opts?: object): void;
|
899 | assertStringLiteralTypeAnnotation(opts?: object): void;
|
900 | assertStringTypeAnnotation(opts?: object): void;
|
901 | assertThisTypeAnnotation(opts?: object): void;
|
902 | assertTupleTypeAnnotation(opts?: object): void;
|
903 | assertTypeofTypeAnnotation(opts?: object): void;
|
904 | assertTypeAlias(opts?: object): void;
|
905 | assertTypeAnnotation(opts?: object): void;
|
906 | assertTypeCastExpression(opts?: object): void;
|
907 | assertTypeParameterDeclaration(opts?: object): void;
|
908 | assertTypeParameterInstantiation(opts?: object): void;
|
909 | assertObjectTypeAnnotation(opts?: object): void;
|
910 | assertObjectTypeCallProperty(opts?: object): void;
|
911 | assertObjectTypeIndexer(opts?: object): void;
|
912 | assertObjectTypeProperty(opts?: object): void;
|
913 | assertQualifiedTypeIdentifier(opts?: object): void;
|
914 | assertUnionTypeAnnotation(opts?: object): void;
|
915 | assertVoidTypeAnnotation(opts?: object): void;
|
916 | assertJSXAttribute(opts?: object): void;
|
917 | assertJSXClosingElement(opts?: object): void;
|
918 | assertJSXElement(opts?: object): void;
|
919 | assertJSXEmptyExpression(opts?: object): void;
|
920 | assertJSXExpressionContainer(opts?: object): void;
|
921 | assertJSXIdentifier(opts?: object): void;
|
922 | assertJSXMemberExpression(opts?: object): void;
|
923 | assertJSXNamespacedName(opts?: object): void;
|
924 | assertJSXOpeningElement(opts?: object): void;
|
925 | assertJSXSpreadAttribute(opts?: object): void;
|
926 | assertJSXText(opts?: object): void;
|
927 | assertNoop(opts?: object): void;
|
928 | assertParenthesizedExpression(opts?: object): void;
|
929 | assertAwaitExpression(opts?: object): void;
|
930 | assertBindExpression(opts?: object): void;
|
931 | assertDecorator(opts?: object): void;
|
932 | assertDoExpression(opts?: object): void;
|
933 | assertExportDefaultSpecifier(opts?: object): void;
|
934 | assertExportNamespaceSpecifier(opts?: object): void;
|
935 | assertRestProperty(opts?: object): void;
|
936 | assertSpreadProperty(opts?: object): void;
|
937 | assertExpression(opts?: object): void;
|
938 | assertBinary(opts?: object): void;
|
939 | assertScopable(opts?: object): void;
|
940 | assertBlockParent(opts?: object): void;
|
941 | assertBlock(opts?: object): void;
|
942 | assertStatement(opts?: object): void;
|
943 | assertTerminatorless(opts?: object): void;
|
944 | assertCompletionStatement(opts?: object): void;
|
945 | assertConditional(opts?: object): void;
|
946 | assertLoop(opts?: object): void;
|
947 | assertWhile(opts?: object): void;
|
948 | assertExpressionWrapper(opts?: object): void;
|
949 | assertFor(opts?: object): void;
|
950 | assertForXStatement(opts?: object): void;
|
951 | assertFunction(opts?: object): void;
|
952 | assertFunctionParent(opts?: object): void;
|
953 | assertPureish(opts?: object): void;
|
954 | assertDeclaration(opts?: object): void;
|
955 | assertLVal(opts?: object): void;
|
956 | assertLiteral(opts?: object): void;
|
957 | assertImmutable(opts?: object): void;
|
958 | assertUserWhitespacable(opts?: object): void;
|
959 | assertMethod(opts?: object): void;
|
960 | assertObjectMember(opts?: object): void;
|
961 | assertProperty(opts?: object): void;
|
962 | assertUnaryLike(opts?: object): void;
|
963 | assertPattern(opts?: object): void;
|
964 | assertClass(opts?: object): void;
|
965 | assertModuleDeclaration(opts?: object): void;
|
966 | assertExportDeclaration(opts?: object): void;
|
967 | assertModuleSpecifier(opts?: object): void;
|
968 | assertFlow(opts?: object): void;
|
969 | assertFlowBaseAnnotation(opts?: object): void;
|
970 | assertFlowDeclaration(opts?: object): void;
|
971 | assertJSX(opts?: object): void;
|
972 | assertNumberLiteral(opts?: object): void;
|
973 | assertRegexLiteral(opts?: object): void;
|
974 | }
|
975 |
|
976 | export class Hub {
|
977 | constructor(file: any, options: any);
|
978 | file: any;
|
979 | options: any;
|
980 | }
|
981 |
|
982 | export interface TraversalContext {
|
983 | parentPath: NodePath;
|
984 | scope: Scope;
|
985 | state: any;
|
986 | opts: any;
|
987 | }
|
988 |
|
\ | No newline at end of file |