@stylexjs/babel-plugin 0.2.0-beta.9 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +2 -4
  2. package/flow_modules/@babel/core/index.js.flow +854 -0
  3. package/flow_modules/@babel/generator/index.js.flow +216 -0
  4. package/flow_modules/@babel/helper-module-imports/index.js.flow +182 -0
  5. package/flow_modules/@babel/parser/index.js.flow +253 -0
  6. package/flow_modules/@babel/traverse/index.js.flow +1003 -0
  7. package/flow_modules/@babel/types/index.js.flow +5224 -0
  8. package/lib/babel-path-utils.d.ts +1100 -0
  9. package/lib/babel-path-utils.js.flow +1108 -0
  10. package/lib/index.d.ts +46 -0
  11. package/lib/index.js +4082 -2822
  12. package/lib/index.js.flow +50 -0
  13. package/lib/utils/dev-classname.d.ts +26 -0
  14. package/lib/utils/dev-classname.js.flow +31 -0
  15. package/lib/utils/evaluate-path.d.ts +29 -0
  16. package/lib/utils/evaluate-path.js.flow +37 -0
  17. package/lib/utils/helpers.d.ts +12 -0
  18. package/lib/utils/helpers.js.flow +10 -0
  19. package/lib/utils/js-to-ast.d.ts +23 -0
  20. package/lib/utils/js-to-ast.js.flow +25 -0
  21. package/lib/utils/state-manager.d.ts +110 -0
  22. package/lib/utils/state-manager.js.flow +91 -0
  23. package/lib/visitors/imports.d.ts +20 -0
  24. package/lib/visitors/imports.js.flow +24 -0
  25. package/lib/visitors/stylex-create/index.d.ts +17 -0
  26. package/lib/visitors/stylex-create/index.js.flow +24 -0
  27. package/lib/visitors/stylex-create/parse-stylex-create-arg.d.ts +28 -0
  28. package/lib/visitors/stylex-create/parse-stylex-create-arg.js.flow +30 -0
  29. package/lib/visitors/stylex-create-theme.d.ts +17 -0
  30. package/lib/visitors/stylex-create-theme.js.flow +23 -0
  31. package/lib/visitors/stylex-define-vars.d.ts +17 -0
  32. package/lib/visitors/stylex-define-vars.js.flow +23 -0
  33. package/lib/visitors/stylex-keyframes.d.ts +17 -0
  34. package/lib/visitors/stylex-keyframes.js.flow +23 -0
  35. package/lib/visitors/stylex-merge.d.ts +21 -0
  36. package/lib/visitors/stylex-merge.js.flow +25 -0
  37. package/lib/visitors/stylex-props.d.ts +21 -0
  38. package/lib/visitors/stylex-props.js.flow +25 -0
  39. package/package.json +15 -13
@@ -0,0 +1,1003 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import * as t from '../types';
11
+
12
+ export type Node = t.Node;
13
+
14
+ declare var traverse: {
15
+ <S>(
16
+ parent: ?Node | $ReadOnlyArray<Node>,
17
+ opts: TraverseOptions<S>,
18
+ scope: Scope | void,
19
+ state: S,
20
+ parentPath?: NodePath<>,
21
+ ): void,
22
+ (
23
+ parent: ?Node | $ReadOnlyArray<Node>,
24
+ opts?: TraverseOptions<>,
25
+ scope?: Scope,
26
+ state?: mixed,
27
+ parentPath?: NodePath<>,
28
+ ): void,
29
+
30
+ visitors: typeof visitors,
31
+ verify: typeof visitors.verify,
32
+ explode: typeof visitors.explode,
33
+ };
34
+
35
+ export default traverse;
36
+
37
+ declare export var visitors: {
38
+ /**
39
+ * `explode()` will take a `Visitor` object with all of the various shorthands
40
+ * that we support, and validates & normalizes it into a common format, ready
41
+ * to be used in traversal.
42
+ *
43
+ * The various shorthands are:
44
+ * - `Identifier() { ... }` -> `Identifier: { enter() { ... } }`
45
+ * - `"Identifier|NumericLiteral": { ... }` -> `Identifier: { ... }, NumericLiteral: { ... }`
46
+ * - Aliases in `@babel/types`: e.g. `Property: { ... }` -> `ObjectProperty: { ... }, ClassProperty: { ... }`
47
+ *
48
+ * Other normalizations are:
49
+ * - Visitors of virtual types are wrapped, so that they are only visited when their dynamic check passes
50
+ * - `enter` and `exit` functions are wrapped in arrays, to ease merging of visitors
51
+ */
52
+ +explode: <S: { +[string]: mixed } = { +[string]: mixed }>(
53
+ visitor: Visitor<S>,
54
+ ) => { [key: $Keys<t._NodeMap>]: ?VisitNodeObject<S, Node> },
55
+ +verify: (visitor: Visitor<>) => void,
56
+ +merge: <S = {}>(visitors: Array<Visitor<S>>, states?: S[]) => Visitor<mixed>,
57
+ };
58
+
59
+ // TODO: Change to object type
60
+ export type TraverseOptions<S: Node = Node> = $ReadOnly<{
61
+ ...Visitor<S>,
62
+ scope?: Scope | void,
63
+ noScope?: boolean | void,
64
+ }>;
65
+
66
+ // TODO: Is this possible??
67
+ // export type ArrayKeys<T> = keyof { [P in keyof T as T[P] extends any[] ? P : never]: P };
68
+
69
+ declare export class Scope {
70
+ constructor(path: NodePath<>, parentScope?: Scope): Scope;
71
+ path: NodePath<>;
72
+ block: Node;
73
+ parentBlock: Node;
74
+ parent: Scope;
75
+ hub: HubInterface;
76
+ bindings: { [name: string]: Binding };
77
+
78
+ /** Traverse node with current scope and path. */
79
+ traverse<S>(node: Node | Node[], opts: TraverseOptions<S>, state: S): void;
80
+ traverse(node: Node | Node[], opts?: TraverseOptions<>, state?: any): void;
81
+
82
+ /** Generate a unique identifier and add it to the current scope. */
83
+ generateDeclaredUidIdentifier(name?: string): t.Identifier;
84
+
85
+ /** Generate a unique identifier. */
86
+ generateUidIdentifier(name?: string): t.Identifier;
87
+
88
+ /** Generate a unique `_id1` binding. */
89
+ generateUid(name?: string): string;
90
+
91
+ /** Generate a unique identifier based on a node. */
92
+ generateUidIdentifierBasedOnNode(
93
+ parent: Node,
94
+ defaultName?: string,
95
+ ): t.Identifier;
96
+
97
+ /**
98
+ * Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
99
+ * evaluating it wont result in potentially arbitrary code from being ran. The following are
100
+ * whitelisted and determined not to cause side effects:
101
+ *
102
+ * - `this` expressions
103
+ * - `super` expressions
104
+ * - Bound identifiers
105
+ */
106
+ isStatic(node: Node): boolean;
107
+
108
+ /** Possibly generate a memoised identifier if it is not static and has consequences. */
109
+ maybeGenerateMemoised(node: Node, dontPush?: boolean): t.Identifier;
110
+
111
+ checkBlockScopedCollisions(
112
+ local: Binding,
113
+ kind: BindingKind,
114
+ name: string,
115
+ id: object,
116
+ ): void;
117
+
118
+ rename(oldName: string, newName?: string, block?: Node): void;
119
+
120
+ dump(): void;
121
+
122
+ toArray(node: Node, i?: number): Node;
123
+
124
+ registerDeclaration(path: NodePath<>): void;
125
+
126
+ buildUndefinedNode(): Node;
127
+
128
+ registerConstantViolation(path: NodePath<>): void;
129
+
130
+ registerBinding(
131
+ kind: string,
132
+ path: NodePath<>,
133
+ bindingPath?: NodePath<>,
134
+ ): void;
135
+
136
+ addGlobal(node: Node): void;
137
+
138
+ hasUid(name: string): boolean;
139
+
140
+ hasGlobal(name: string): boolean;
141
+
142
+ hasReference(name: string): boolean;
143
+
144
+ isPure(node: Node, constantsOnly?: boolean): boolean;
145
+
146
+ setData(key: string, val: any): any;
147
+
148
+ getData(key: string): any;
149
+
150
+ removeData(key: string): void;
151
+
152
+ crawl(): void;
153
+
154
+ push(opts: {
155
+ id: t.LVal,
156
+ init?: t.Expression | void,
157
+ unique?: boolean | void,
158
+ kind?: 'var' | 'let' | 'const' | void,
159
+ }): void;
160
+
161
+ getProgramParent(): Scope;
162
+
163
+ getFunctionParent(): Scope | null;
164
+
165
+ getBlockParent(): Scope;
166
+
167
+ /** Walks the scope tree and gathers **all** bindings. */
168
+ getAllBindings<T: string>(...kinds: $ReadOnlyArray<T>): {
169
+ +[key: T]: Binding,
170
+ };
171
+
172
+ bindingIdentifierEquals(name: string, node: Node): boolean;
173
+
174
+ getBinding(name: string): Binding | void;
175
+
176
+ getOwnBinding(name: string): Binding | void;
177
+
178
+ getBindingIdentifier(name: string): t.Identifier;
179
+
180
+ getOwnBindingIdentifier(name: string): t.Identifier;
181
+
182
+ hasOwnBinding(name: string): boolean;
183
+
184
+ hasBinding(name: string, noGlobals?: boolean): boolean;
185
+
186
+ parentHasBinding(name: string, noGlobals?: boolean): boolean;
187
+
188
+ /** Move a binding of `name` to another `scope`. */
189
+ moveBindingTo(name: string, scope: Scope): void;
190
+
191
+ removeOwnBinding(name: string): void;
192
+
193
+ removeBinding(name: string): void;
194
+ }
195
+
196
+ export type BindingKind =
197
+ | 'var'
198
+ | 'let'
199
+ | 'const'
200
+ | 'module'
201
+ | 'hoisted'
202
+ | 'param'
203
+ | 'local'
204
+ | 'unknown';
205
+
206
+ declare export class Binding {
207
+ constructor(opts: {
208
+ identifier: t.Identifier,
209
+ scope: Scope,
210
+ path: NodePath<>,
211
+ kind: BindingKind,
212
+ }): Binding;
213
+ identifier: t.Identifier;
214
+ scope: Scope;
215
+ path: NodePath<>;
216
+ kind: BindingKind;
217
+ referenced: boolean;
218
+ references: number;
219
+ referencePaths: $ReadOnlyArray<NodePath<>>;
220
+ constant: boolean;
221
+ constantViolations: $ReadOnlyArray<NodePath<>>;
222
+ hasDeoptedValue?: boolean;
223
+ hasValue: ?boolean;
224
+ value?: any;
225
+
226
+ deopValue(): void;
227
+ setValue(value: any): void;
228
+ clearValue(): void;
229
+
230
+ reassign(path: NodePath<>): void;
231
+ reference(path: NodePath<>): void;
232
+ dereference(): void;
233
+ }
234
+
235
+ // TODO: Change to object type
236
+ type _VisitorNodeKeys<S: object> = {
237
+ +[K in keyof t._NodeMap]: ?VisitNode<S, t._NodeMap[K]>,
238
+ };
239
+ type _VistorAliases<S: object> = {
240
+ +[K in keyof t.Aliases]: ?VisitNode<S, t.Aliases[K]>,
241
+ };
242
+
243
+ export type Visitor<S: object = object> = $ReadOnly<
244
+ Partial<{
245
+ ...VisitNodeObject<S, Node>,
246
+ ..._VisitorNodeKeys<S>,
247
+ ..._VistorAliases<S>,
248
+ }>,
249
+ >;
250
+
251
+ export type VisitNode<S, P: Node> =
252
+ | VisitNodeFunction<S, P>
253
+ | VisitNodeObject<S, P>;
254
+
255
+ export type VisitNodeFunction<S, P: Node> = (
256
+ this: S,
257
+ path: NodePath<P>,
258
+ state: S,
259
+ ) => void;
260
+
261
+ type NodeType = Node['type'] | $Keys<t.Aliases>;
262
+
263
+ // TODO: Change to object type??
264
+ export type VisitNodeObject<S, P: Node> = {
265
+ enter?: VisitNodeFunction<S, P> | void,
266
+ exit?: VisitNodeFunction<S, P> | void,
267
+ denylist?: NodeType[] | void,
268
+ /**
269
+ * @deprecated will be removed in Babel 8
270
+ */
271
+ // blacklist?: NodeType[] | void,
272
+ };
273
+
274
+ type _NodeToTuple<T: Node | $ReadOnlyArray<Node>> =
275
+ T extends $ReadOnlyArray<Node> ? T : [T];
276
+
277
+ export type NodePaths<T: Node | $ReadOnlyArray<Node>> = $TupleMap<
278
+ _NodeToTuple<T>,
279
+ <TNode: Node>(TNode) => NodePath<TNode>,
280
+ >;
281
+
282
+ type TParentPath<T: Node> = T extends t.Program ? null : NodePath<>;
283
+
284
+ interface object {}
285
+
286
+ declare export class NodePath<+T: Node = Node> {
287
+ constructor(hub: Hub, parent: Node): NodePath<T>;
288
+ parent: Node;
289
+ hub: Hub;
290
+ contexts: $ReadOnlyArray<TraversalContext>;
291
+ data: object;
292
+ shouldSkip: boolean;
293
+ shouldStop: boolean;
294
+ removed: boolean;
295
+ state: any;
296
+ opts: object;
297
+ skipKeys: object;
298
+ parentPath: TParentPath<T>;
299
+ context: TraversalContext;
300
+ container: object | $ReadOnlyArray<object>;
301
+ listKey: string;
302
+ inList: boolean;
303
+ parentKey: string;
304
+ key: string | number;
305
+ node: T;
306
+ scope: Scope;
307
+
308
+ type: T extends null | void
309
+ ? void
310
+ : T extends Node
311
+ ? T['type']
312
+ : string | void;
313
+
314
+ typeAnnotation: { ... };
315
+
316
+ getScope(scope: Scope): Scope;
317
+
318
+ setData(key: string, val: any): any;
319
+
320
+ getData(key: string, def?: any): any;
321
+
322
+ hasNode(this: NodePath<>): boolean; // this is NodePath<$NonMaybeType<this['node']>>;
323
+
324
+ buildCodeFrameError<TError: Error>(
325
+ msg: string,
326
+ Error?: Class<TError>,
327
+ ): TError;
328
+
329
+ traverse<T: object>(visitor: Visitor<T>, state?: T): void;
330
+ // traverse(visitor: Visitor<>): void;
331
+
332
+ set(key: string, node: Node): void;
333
+
334
+ getPathLocation(): string;
335
+
336
+ // Example: https://github.com/babel/babel/blob/63204ae51e020d84a5b246312f5eeb4d981ab952/packages/babel-traverse/src/path/modification.js#L83
337
+ debug(buildMessage: () => string): void;
338
+
339
+ static get<C: Node, K: $Keys<C>>(opts: {
340
+ hub: HubInterface,
341
+ parentPath: NodePath<> | null,
342
+ parent: Node,
343
+ container: C,
344
+ listKey?: string | void,
345
+ key: K,
346
+ }): NodePath<C[K]>;
347
+
348
+ //#region ------------------------- ancestry -------------------------
349
+ /**
350
+ * Starting at the parent path of the current `NodePath` and going up the
351
+ * tree, return the first `NodePath` that causes the provided `callback`
352
+ * to return a truthy value, or `null` if the `callback` never returns a
353
+ * truthy value.
354
+ */
355
+ findParent(callback: (path: NodePath<>) => boolean): NodePath<> | null;
356
+
357
+ /**
358
+ * Starting at current `NodePath` and going up the tree, return the first
359
+ * `NodePath` that causes the provided `callback` to return a truthy value,
360
+ * or `null` if the `callback` never returns a truthy value.
361
+ */
362
+ find(callback: (path: NodePath<>) => boolean): NodePath<> | null;
363
+
364
+ /** Get the parent function of the current path. */
365
+ getFunctionParent(): NodePath<t.Function> | null;
366
+
367
+ /** Walk up the tree until we hit a parent node path in a list. */
368
+ getStatementParent(): NodePath<t.Statement> | null;
369
+
370
+ /**
371
+ * Get the deepest common ancestor and then from it, get the earliest relationship path
372
+ * to that ancestor.
373
+ *
374
+ * Earliest is defined as being "before" all the other nodes in terms of list container
375
+ * position and visiting key.
376
+ */
377
+ getEarliestCommonAncestorFrom(paths: $ReadOnlyArray<NodePath<>>): NodePath<>;
378
+
379
+ /** Get the earliest path in the tree where the provided `paths` intersect. */
380
+ getDeepestCommonAncestorFrom(
381
+ paths: $ReadOnlyArray<NodePath<>>,
382
+ filter?: (
383
+ deepest: Node,
384
+ i: number,
385
+ ancestries: $ReadOnlyArray<NodePath<>>,
386
+ ) => NodePath<>,
387
+ ): NodePath<>;
388
+
389
+ /**
390
+ * Build an array of node paths containing the entire ancestry of the current node path.
391
+ *
392
+ * NOTE: The current node path is included in this.
393
+ */
394
+ getAncestry(): $ReadOnlyArray<NodePath<>>;
395
+
396
+ /**
397
+ * A helper to find if `this` path is an ancestor of `maybeDescendant`
398
+ */
399
+ isAncestor(maybeDescendant: NodePath<>): boolean;
400
+
401
+ /**
402
+ * A helper to find if `this` path is a descendant of `maybeAncestor`
403
+ */
404
+ isDescendant(maybeAncestor: NodePath<>): boolean;
405
+
406
+ inType(...candidateTypes: Array<string>): boolean;
407
+ //#endregion
408
+
409
+ //#region ------------------------- inference -------------------------
410
+ /** Infer the type of the current `NodePath`. */
411
+ getTypeAnnotation(): t.FlowType;
412
+
413
+ isBaseType(baseName: string, soft?: boolean): boolean;
414
+
415
+ couldBeBaseType(name: string): boolean;
416
+
417
+ baseTypeStrictlyMatches(right: NodePath<>): boolean;
418
+
419
+ isGenericType(genericName: string): boolean;
420
+ //#endregion
421
+
422
+ //#region ------------------------- replacement -------------------------
423
+ /**
424
+ * Replace a node with an array of multiple. This method performs the following steps:
425
+ *
426
+ * - Inherit the comments of first provided node with that of the current node.
427
+ * - Insert the provided nodes after the current node.
428
+ * - Remove the current node.
429
+ */
430
+ replaceWithMultiple<Nodes: $ReadOnlyArray<Node>>(
431
+ nodes: Nodes,
432
+ ): NodePaths<Nodes>;
433
+
434
+ /**
435
+ * Parse a string as an expression and replace the current node with the result.
436
+ *
437
+ * NOTE: This is typically not a good idea to use. Building source strings when
438
+ * transforming ASTs is an antipattern and SHOULD NOT be encouraged. Even if it's
439
+ * easier to use, your transforms will be extremely brittle.
440
+ */
441
+ replaceWithSourceString(replacement: any): [NodePath<>];
442
+
443
+ /** Replace the current node with another. */
444
+ replaceWith<T: Node>(replacement: T | NodePath<T>): [NodePath<T>];
445
+
446
+ /**
447
+ * This method takes an array of statements nodes and then explodes it
448
+ * into expressions. This method retains completion records which is
449
+ * extremely important to retain original semantics.
450
+ */
451
+ replaceExpressionWithStatements<Nodes: $ReadOnlyArray<Node>>(
452
+ nodes: Nodes,
453
+ ): NodePaths<Nodes>;
454
+
455
+ replaceInline<Nodes: Node | $ReadOnlyArray<Node>>(
456
+ nodes: Nodes,
457
+ ): NodePaths<Nodes>;
458
+ //#endregion
459
+
460
+ //#region ------------------------- evaluation -------------------------
461
+ /**
462
+ * Walk the input `node` and statically evaluate if it's truthy.
463
+ *
464
+ * Returning `true` when we're sure that the expression will evaluate to a
465
+ * truthy value, `false` if we're sure that it will evaluate to a falsy
466
+ * value and `undefined` if we aren't sure. Because of this please do not
467
+ * rely on coercion when using this method and check with === if it's false.
468
+ */
469
+ evaluateTruthy(): boolean;
470
+
471
+ /**
472
+ * Walk the input `node` and statically evaluate it.
473
+ *
474
+ * Returns an object in the form `{ confident, value }`. `confident` indicates
475
+ * whether or not we had to drop out of evaluating the expression because of
476
+ * hitting an unknown node that we couldn't confidently find the value of.
477
+ *
478
+ * Example:
479
+ *
480
+ * t.evaluate(parse("5 + 5")) // { confident: true, value: 10 }
481
+ * t.evaluate(parse("!true")) // { confident: true, value: false }
482
+ * t.evaluate(parse("foo + foo")) // { confident: false, value: undefined }
483
+ */
484
+ evaluate(): { confident: boolean, value: any };
485
+ //#endregion
486
+
487
+ //#region ------------------------- introspection -------------------------
488
+ /**
489
+ * Match the current node if it matches the provided `pattern`.
490
+ *
491
+ * For example, given the match `React.createClass` it would match the
492
+ * parsed nodes of `React.createClass` and `React["createClass"]`.
493
+ */
494
+ matchesPattern(pattern: string, allowPartial?: boolean): boolean;
495
+
496
+ /**
497
+ * Check whether we have the input `key`. If the `key` references an array then we check
498
+ * if the array has any items, otherwise we just check if it's falsy.
499
+ */
500
+ has(key: string): boolean;
501
+
502
+ isStatic(): boolean;
503
+
504
+ /** Alias of `has`. */
505
+ is(key: string): boolean;
506
+
507
+ /** Opposite of `has`. */
508
+ isnt(key: string): boolean;
509
+
510
+ /** Check whether the path node `key` strict equals `value`. */
511
+ equals(key: string, value: any): boolean;
512
+
513
+ /**
514
+ * Check the type against our stored internal type of the node. This is handy when a node has
515
+ * been removed yet we still internally know the type and need it to calculate node replacement.
516
+ */
517
+ isNodeType(type: string): boolean;
518
+
519
+ /**
520
+ * This checks whether or not we're in one of the following positions:
521
+ *
522
+ * for (KEY in right);
523
+ * for (KEY;;);
524
+ *
525
+ * This is because these spots allow VariableDeclarations AND normal expressions so we need
526
+ * to tell the path replacement that it's ok to replace this with an expression.
527
+ */
528
+ canHaveVariableDeclarationOrExpression(): boolean;
529
+
530
+ /**
531
+ * This checks whether we are swapping an arrow function's body between an
532
+ * expression and a block statement (or vice versa).
533
+ *
534
+ * This is because arrow functions may implicitly return an expression, which
535
+ * is the same as containing a block statement.
536
+ */
537
+ canSwapBetweenExpressionAndStatement(replacement: Node): boolean;
538
+
539
+ /** Check whether the current path references a completion record */
540
+ isCompletionRecord(allowInsideFunction?: boolean): boolean;
541
+
542
+ /**
543
+ * Check whether or not the current `key` allows either a single statement or block statement
544
+ * so we can explode it if necessary.
545
+ */
546
+ isStatementOrBlock(): boolean;
547
+
548
+ /** Check if the currently assigned path references the `importName` of `moduleSource`. */
549
+ referencesImport(moduleSource: string, importName: string): boolean;
550
+
551
+ /** Get the source code associated with this node. */
552
+ getSource(): string;
553
+
554
+ /** Check if the current path will maybe execute before another path */
555
+ willIMaybeExecuteBefore(path: NodePath<>): boolean;
556
+ //#endregion
557
+
558
+ //#region ------------------------- context -------------------------
559
+ call(key: string): boolean;
560
+
561
+ isBlacklisted(): boolean;
562
+
563
+ visit(): boolean;
564
+
565
+ skip(): void;
566
+
567
+ skipKey(key: string): void;
568
+
569
+ stop(): void;
570
+
571
+ setScope(): void;
572
+
573
+ setContext(context?: TraversalContext): this;
574
+
575
+ popContext(): void;
576
+
577
+ pushContext(context: TraversalContext): void;
578
+ //#endregion
579
+
580
+ //#region ------------------------- removal -------------------------
581
+ remove(): void;
582
+ //#endregion
583
+
584
+ //#region ------------------------- modification -------------------------
585
+ /** Insert the provided nodes before the current one. */
586
+ insertBefore<Nodes: Node | $ReadOnlyArray<Node>>(
587
+ nodes: Nodes,
588
+ ): NodePaths<Nodes>;
589
+
590
+ /**
591
+ * Insert the provided nodes after the current one. When inserting nodes after an
592
+ * expression, ensure that the completion record is correct by pushing the current node.
593
+ */
594
+ insertAfter<Nodes: Node | $ReadOnlyArray<Node>>(
595
+ nodes: Nodes,
596
+ ): NodePaths<Nodes>;
597
+
598
+ /** Update all sibling node paths after `fromIndex` by `incrementBy`. */
599
+ updateSiblingKeys(fromIndex: number, incrementBy: number): void;
600
+
601
+ /**
602
+ * Insert child nodes at the start of the current node.
603
+ * @param listKey - The key at which the child nodes are stored (usually body).
604
+ * @param nodes - the nodes to insert.
605
+ */
606
+ unshiftContainer<Nodes: Node | $ReadOnlyArray<Node>>(
607
+ listKey: $Keys<T>,
608
+ nodes: Nodes,
609
+ ): NodePaths<Nodes>;
610
+
611
+ /**
612
+ * Insert child nodes at the end of the current node.
613
+ * @param listKey - The key at which the child nodes are stored (usually body).
614
+ * @param nodes - the nodes to insert.
615
+ */
616
+ pushContainer<Nodes: Node | $ReadOnlyArray<Node>>(
617
+ listKey: $Keys<T>,
618
+ nodes: Nodes,
619
+ ): NodePaths<Nodes>;
620
+
621
+ /** Hoist the current node to the highest scope possible and return a UID referencing it. */
622
+ hoist(scope: Scope): void;
623
+ //#endregion
624
+
625
+ //#region ------------------------- family -------------------------
626
+ getOpposite(): NodePath<>;
627
+
628
+ getCompletionRecords(): Array<NodePath<>>;
629
+
630
+ getSibling(key: string | number): NodePath<>;
631
+ getPrevSibling(): NodePath<>;
632
+ getNextSibling(): NodePath<>;
633
+ getAllPrevSiblings(): Array<NodePath<>>;
634
+ getAllNextSiblings(): Array<NodePath<>>;
635
+
636
+ get<K: $Keys<T>>(
637
+ key: K,
638
+ context?: boolean | TraversalContext,
639
+ ): NodePathResult<$NonMaybeType<T[K]>> | T[K] extends null | void
640
+ ? null
641
+ : empty;
642
+ // get(key: string, context?: boolean | TraversalContext): NodePath | NodePath[];
643
+
644
+ getBindingIdentifiers(duplicates: true): Record<string, t.Identifier[]>;
645
+ getBindingIdentifiers(duplicates?: false): Record<string, t.Identifier>;
646
+ getBindingIdentifiers(
647
+ duplicates?: boolean,
648
+ ): Record<string, t.Identifier | t.Identifier[]>;
649
+
650
+ getOuterBindingIdentifiers(duplicates: true): Record<string, t.Identifier[]>;
651
+ getOuterBindingIdentifiers(duplicates?: false): Record<string, t.Identifier>;
652
+ getOuterBindingIdentifiers(
653
+ duplicates?: boolean,
654
+ ): Record<string, t.Identifier | t.Identifier[]>;
655
+
656
+ getBindingIdentifierPaths(
657
+ duplicates: true,
658
+ outerOnly?: boolean,
659
+ ): Record<string, Array<NodePath<t.Identifier>>>;
660
+ getBindingIdentifierPaths(
661
+ duplicates?: false,
662
+ outerOnly?: boolean,
663
+ ): Record<string, NodePath<t.Identifier>>;
664
+ getBindingIdentifierPaths(
665
+ duplicates?: boolean,
666
+ outerOnly?: boolean,
667
+ ): Record<string, NodePath<t.Identifier> | Array<NodePath<t.Identifier>>>;
668
+
669
+ getOuterBindingIdentifierPaths(
670
+ duplicates: true,
671
+ ): Record<string, Array<NodePath<t.Identifier>>>;
672
+ getOuterBindingIdentifierPaths(
673
+ duplicates?: false,
674
+ ): Record<string, NodePath<t.Identifier>>;
675
+ getOuterBindingIdentifierPaths(
676
+ duplicates?: boolean,
677
+ outerOnly?: boolean,
678
+ ): Record<string, NodePath<t.Identifier> | Array<NodePath<t.Identifier>>>;
679
+ //#endregion
680
+
681
+ //#region ------------------------- comments -------------------------
682
+ /** Share comments amongst siblings. */
683
+ shareCommentsWithSiblings(): void;
684
+
685
+ addComment(type: string, content: string, line?: boolean): void;
686
+
687
+ /** Give node `comments` of the specified `type`. */
688
+ addComments(type: string, comments: any[]): void;
689
+ //#endregion
690
+
691
+ //#region ------------------------- isXXX -------------------------
692
+ // isAnyTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.AnyTypeAnnotation>;
693
+ // isArrayExpression(props?: object | null): boolean; // this is NodePath<t.ArrayExpression>;
694
+ // isArrayPattern(props?: object | null): boolean; // this is NodePath<t.ArrayPattern>;
695
+ // isArrayTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.ArrayTypeAnnotation>;
696
+ // isArrowFunctionExpression(props?: object | null): boolean; // this is NodePath<t.ArrowFunctionExpression>;
697
+ // isAssignmentExpression(props?: object | null): boolean; // this is NodePath<t.AssignmentExpression>;
698
+ // isAssignmentPattern(props?: object | null): boolean; // this is NodePath<t.AssignmentPattern>;
699
+ // isAwaitExpression(props?: object | null): boolean; // this is NodePath<t.AwaitExpression>;
700
+ // isBigIntLiteral(props?: object | null): boolean; // this is NodePath<t.BigIntLiteral>;
701
+ // isBinary(props?: object | null): boolean; // this is NodePath<t.Binary>;
702
+ // isBinaryExpression(props?: object | null): boolean; // this is NodePath<t.BinaryExpression>;
703
+ // isBindExpression(props?: object | null): boolean; // this is NodePath<t.BindExpression>;
704
+ // isBlock(props?: object | null): boolean; // this is NodePath<t.Block>;
705
+ // isBlockParent(props?: object | null): boolean; // this is NodePath<t.BlockParent>;
706
+ // isBlockStatement(props?: object | null): boolean; // this is NodePath<t.BlockStatement>;
707
+ // isBooleanLiteral(props?: object | null): boolean; // this is NodePath<t.BooleanLiteral>;
708
+ // isBooleanLiteralTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.BooleanLiteralTypeAnnotation>;
709
+ // isBooleanTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.BooleanTypeAnnotation>;
710
+ // isBreakStatement(props?: object | null): boolean; // this is NodePath<t.BreakStatement>;
711
+ // isCallExpression(props?: object | null): boolean; // this is NodePath<t.CallExpression>;
712
+ // isCatchClause(props?: object | null): boolean; // this is NodePath<t.CatchClause>;
713
+ // isClass(props?: object | null): boolean; // this is NodePath<t.Class>;
714
+ // isClassBody(props?: object | null): boolean; // this is NodePath<t.ClassBody>;
715
+ // isClassDeclaration(props?: object | null): boolean; // this is NodePath<t.ClassDeclaration>;
716
+ // isClassExpression(props?: object | null): boolean; // this is NodePath<t.ClassExpression>;
717
+ // isClassImplements(props?: object | null): boolean; // this is NodePath<t.ClassImplements>;
718
+ // isClassMethod(props?: object | null): boolean; // this is NodePath<t.ClassMethod>;
719
+ // isClassPrivateMethod(props?: object | null): boolean; // this is NodePath<t.ClassPrivateMethod>;
720
+ // isClassPrivateProperty(props?: object | null): boolean; // this is NodePath<t.ClassPrivateProperty>;
721
+ // isClassProperty(props?: object | null): boolean; // this is NodePath<t.ClassProperty>;
722
+ // isCompletionStatement(props?: object | null): boolean; // this is NodePath<t.CompletionStatement>;
723
+ // isConditional(props?: object | null): boolean; // this is NodePath<t.Conditional>;
724
+ // isConditionalExpression(props?: object | null): boolean; // this is NodePath<t.ConditionalExpression>;
725
+ // isContinueStatement(props?: object | null): boolean; // this is NodePath<t.ContinueStatement>;
726
+ // isDebuggerStatement(props?: object | null): boolean; // this is NodePath<t.DebuggerStatement>;
727
+ // isDeclaration(props?: object | null): boolean; // this is NodePath<t.Declaration>;
728
+ // isDeclareClass(props?: object | null): boolean; // this is NodePath<t.DeclareClass>;
729
+ // isDeclareExportAllDeclaration(props?: object | null): boolean; // this is NodePath<t.DeclareExportAllDeclaration>;
730
+ // isDeclareExportDeclaration(props?: object | null): boolean; // this is NodePath<t.DeclareExportDeclaration>;
731
+ // isDeclareFunction(props?: object | null): boolean; // this is NodePath<t.DeclareFunction>;
732
+ // isDeclareInterface(props?: object | null): boolean; // this is NodePath<t.DeclareInterface>;
733
+ // isDeclareModule(props?: object | null): boolean; // this is NodePath<t.DeclareModule>;
734
+ // isDeclareModuleExports(props?: object | null): boolean; // this is NodePath<t.DeclareModuleExports>;
735
+ // isDeclareOpaqueType(props?: object | null): boolean; // this is NodePath<t.DeclareOpaqueType>;
736
+ // isDeclareTypeAlias(props?: object | null): boolean; // this is NodePath<t.DeclareTypeAlias>;
737
+ // isDeclareVariable(props?: object | null): boolean; // this is NodePath<t.DeclareVariable>;
738
+ // isDeclaredPredicate(props?: object | null): boolean; // this is NodePath<t.DeclaredPredicate>;
739
+ // isDecorator(props?: object | null): boolean; // this is NodePath<t.Decorator>;
740
+ // isDirective(props?: object | null): boolean; // this is NodePath<t.Directive>;
741
+ // isDirectiveLiteral(props?: object | null): boolean; // this is NodePath<t.DirectiveLiteral>;
742
+ // isDoExpression(props?: object | null): boolean; // this is NodePath<t.DoExpression>;
743
+ // isDoWhileStatement(props?: object | null): boolean; // this is NodePath<t.DoWhileStatement>;
744
+ // isEmptyStatement(props?: object | null): boolean; // this is NodePath<t.EmptyStatement>;
745
+ // isEmptyTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.EmptyTypeAnnotation>;
746
+ // isExistsTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.ExistsTypeAnnotation>;
747
+ // isExportAllDeclaration(props?: object | null): boolean; // this is NodePath<t.ExportAllDeclaration>;
748
+ // isExportDeclaration(props?: object | null): boolean; // this is NodePath<t.ExportDeclaration>;
749
+ // isExportDefaultDeclaration(props?: object | null): boolean; // this is NodePath<t.ExportDefaultDeclaration>;
750
+ // isExportDefaultSpecifier(props?: object | null): boolean; // this is NodePath<t.ExportDefaultSpecifier>;
751
+ // isExportNamedDeclaration(props?: object | null): boolean; // this is NodePath<t.ExportNamedDeclaration>;
752
+ // isExportNamespaceSpecifier(props?: object | null): boolean; // this is NodePath<t.ExportNamespaceSpecifier>;
753
+ // isExportSpecifier(props?: object | null): boolean; // this is NodePath<t.ExportSpecifier>;
754
+ // isExpression(props?: object | null): boolean; // this is NodePath<t.Expression>;
755
+ // isExpressionStatement(props?: object | null): boolean; // this is NodePath<t.ExpressionStatement>;
756
+ // isExpressionWrapper(props?: object | null): boolean; // this is NodePath<t.ExpressionWrapper>;
757
+ // isFile(props?: object | null): boolean; // this is NodePath<t.File>;
758
+ // isFlow(props?: object | null): boolean; // this is NodePath<t.Flow>;
759
+ // isFlowBaseAnnotation(props?: object | null): boolean; // this is NodePath<t.FlowBaseAnnotation>;
760
+ // isFlowDeclaration(props?: object | null): boolean; // this is NodePath<t.FlowDeclaration>;
761
+ // isFlowPredicate(props?: object | null): boolean; // this is NodePath<t.FlowPredicate>;
762
+ // isFlowType(props?: object | null): boolean; // this is NodePath<t.FlowType>;
763
+ // isFor(props?: object | null): boolean; // this is NodePath<t.For>;
764
+ // isForInStatement(props?: object | null): boolean; // this is NodePath<t.ForInStatement>;
765
+ // isForOfStatement(props?: object | null): boolean; // this is NodePath<t.ForOfStatement>;
766
+ // isForStatement(props?: object | null): boolean; // this is NodePath<t.ForStatement>;
767
+ // isForXStatement(props?: object | null): boolean; // this is NodePath<t.ForXStatement>;
768
+ // isFunction(props?: object | null): boolean; // this is NodePath<t.Function>;
769
+ // isFunctionDeclaration(props?: object | null): boolean; // this is NodePath<t.FunctionDeclaration>;
770
+ // isFunctionExpression(props?: object | null): boolean; // this is NodePath<t.FunctionExpression>;
771
+ // isFunctionParent(props?: object | null): boolean; // this is NodePath<t.FunctionParent>;
772
+ // isFunctionTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.FunctionTypeAnnotation>;
773
+ // isFunctionTypeParam(props?: object | null): boolean; // this is NodePath<t.FunctionTypeParam>;
774
+ // isGenericTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.GenericTypeAnnotation>;
775
+ // isIdentifier(props?: object | null): boolean; // this is NodePath<t.Identifier>;
776
+ // isIfStatement(props?: object | null): boolean; // this is NodePath<t.IfStatement>;
777
+ // isImmutable(props?: object | null): boolean; // this is NodePath<t.Immutable>;
778
+ // isImport(props?: object | null): boolean; // this is NodePath<t.Import>;
779
+ // isImportDeclaration(props?: object | null): boolean; // this is NodePath<t.ImportDeclaration>;
780
+ // isImportDefaultSpecifier(props?: object | null): boolean; // this is NodePath<t.ImportDefaultSpecifier>;
781
+ // isImportNamespaceSpecifier(props?: object | null): boolean; // this is NodePath<t.ImportNamespaceSpecifier>;
782
+ // isImportSpecifier(props?: object | null): boolean; // this is NodePath<t.ImportSpecifier>;
783
+ // isInferredPredicate(props?: object | null): boolean; // this is NodePath<t.InferredPredicate>;
784
+ // isInterfaceDeclaration(props?: object | null): boolean; // this is NodePath<t.InterfaceDeclaration>;
785
+ // isInterfaceExtends(props?: object | null): boolean; // this is NodePath<t.InterfaceExtends>;
786
+ // isInterfaceTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.InterfaceTypeAnnotation>;
787
+ // isInterpreterDirective(props?: object | null): boolean; // this is NodePath<t.InterpreterDirective>;
788
+ // isIntersectionTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.IntersectionTypeAnnotation>;
789
+ // isJSX(props?: object | null): boolean; // this is NodePath<t.JSX>;
790
+ // isJSXAttribute(props?: object | null): boolean; // this is NodePath<t.JSXAttribute>;
791
+ // isJSXClosingElement(props?: object | null): boolean; // this is NodePath<t.JSXClosingElement>;
792
+ // isJSXClosingFragment(props?: object | null): boolean; // this is NodePath<t.JSXClosingFragment>;
793
+ // isJSXElement(props?: object | null): boolean; // this is NodePath<t.JSXElement>;
794
+ // isJSXEmptyExpression(props?: object | null): boolean; // this is NodePath<t.JSXEmptyExpression>;
795
+ // isJSXExpressionContainer(props?: object | null): boolean; // this is NodePath<t.JSXExpressionContainer>;
796
+ // isJSXFragment(props?: object | null): boolean; // this is NodePath<t.JSXFragment>;
797
+ // isJSXIdentifier(props?: object | null): boolean; // this is NodePath<t.JSXIdentifier>;
798
+ // isJSXMemberExpression(props?: object | null): boolean; // this is NodePath<t.JSXMemberExpression>;
799
+ // isJSXNamespacedName(props?: object | null): boolean; // this is NodePath<t.JSXNamespacedName>;
800
+ // isJSXOpeningElement(props?: object | null): boolean; // this is NodePath<t.JSXOpeningElement>;
801
+ // isJSXOpeningFragment(props?: object | null): boolean; // this is NodePath<t.JSXOpeningFragment>;
802
+ // isJSXSpreadAttribute(props?: object | null): boolean; // this is NodePath<t.JSXSpreadAttribute>;
803
+ // isJSXSpreadChild(props?: object | null): boolean; // this is NodePath<t.JSXSpreadChild>;
804
+ // isJSXText(props?: object | null): boolean; // this is NodePath<t.JSXText>;
805
+ // isLVal(props?: object | null): boolean; // this is NodePath<t.LVal>;
806
+ // isLabeledStatement(props?: object | null): boolean; // this is NodePath<t.LabeledStatement>;
807
+ // isLiteral(props?: object | null): boolean; // this is NodePath<t.Literal>;
808
+ // isLogicalExpression(props?: object | null): boolean; // this is NodePath<t.LogicalExpression>;
809
+ // isLoop(props?: object | null): boolean; // this is NodePath<t.Loop>;
810
+ // isMemberExpression(props?: object | null): boolean; // this is NodePath<t.MemberExpression>;
811
+ // isMetaProperty(props?: object | null): boolean; // this is NodePath<t.MetaProperty>;
812
+ // isMethod(props?: object | null): boolean; // this is NodePath<t.Method>;
813
+ // isMixedTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.MixedTypeAnnotation>;
814
+ // isModuleDeclaration(props?: object | null): boolean; // this is NodePath<t.ModuleDeclaration>;
815
+ // isModuleSpecifier(props?: object | null): boolean; // this is NodePath<t.ModuleSpecifier>;
816
+ // isNewExpression(props?: object | null): boolean; // this is NodePath<t.NewExpression>;
817
+ // isNoop(props?: object | null): boolean; // this is NodePath<t.Noop>;
818
+ // isNullLiteral(props?: object | null): boolean; // this is NodePath<t.NullLiteral>;
819
+ // isNullLiteralTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.NullLiteralTypeAnnotation>;
820
+ // isNullableTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.NullableTypeAnnotation>;
821
+ // isNumberLiteralTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.NumberLiteralTypeAnnotation>;
822
+ // isNumberTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.NumberTypeAnnotation>;
823
+ // isNumericLiteral(props?: object | null): boolean; // this is NodePath<t.NumericLiteral>;
824
+ // isObjectExpression(props?: object | null): boolean; // this is NodePath<t.ObjectExpression>;
825
+ // isObjectMember(props?: object | null): boolean; // this is NodePath<t.ObjectMember>;
826
+ // isObjectMethod(props?: object | null): boolean; // this is NodePath<t.ObjectMethod>;
827
+ // isObjectPattern(props?: object | null): boolean; // this is NodePath<t.ObjectPattern>;
828
+ // isObjectProperty(props?: object | null): boolean; // this is NodePath<t.ObjectProperty>;
829
+ // isObjectTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.ObjectTypeAnnotation>;
830
+ // isObjectTypeCallProperty(props?: object | null): boolean; // this is NodePath<t.ObjectTypeCallProperty>;
831
+ // isObjectTypeIndexer(props?: object | null): boolean; // this is NodePath<t.ObjectTypeIndexer>;
832
+ // isObjectTypeInternalSlot(props?: object | null): boolean; // this is NodePath<t.ObjectTypeInternalSlot>;
833
+ // isObjectTypeProperty(props?: object | null): boolean; // this is NodePath<t.ObjectTypeProperty>;
834
+ // isObjectTypeSpreadProperty(props?: object | null): boolean; // this is NodePath<t.ObjectTypeSpreadProperty>;
835
+ // isOpaqueType(props?: object | null): boolean; // this is NodePath<t.OpaqueType>;
836
+ // isOptionalCallExpression(props?: object | null): boolean; // this is NodePath<t.OptionalCallExpression>;
837
+ // isOptionalMemberExpression(props?: object | null): boolean; // this is NodePath<t.OptionalMemberExpression>;
838
+ // isParenthesizedExpression(props?: object | null): boolean; // this is NodePath<t.ParenthesizedExpression>;
839
+ // isPattern(props?: object | null): boolean; // this is NodePath<t.Pattern>;
840
+ // isPatternLike(props?: object | null): boolean; // this is NodePath<t.PatternLike>;
841
+ // isPipelineBareFunction(props?: object | null): boolean; // this is NodePath<t.PipelineBareFunction>;
842
+ // isPipelinePrimaryTopicReference(props?: object | null): boolean; // this is NodePath<t.PipelinePrimaryTopicReference>;
843
+ // isPipelineTopicExpression(props?: object | null): boolean; // this is NodePath<t.PipelineTopicExpression>;
844
+ // isPrivate(props?: object | null): boolean; // this is NodePath<t.Private>;
845
+ // isPrivateName(props?: object | null): boolean; // this is NodePath<t.PrivateName>;
846
+ // isProgram(props?: object | null): boolean; // this is NodePath<t.Program>;
847
+ // isProperty(props?: object | null): boolean; // this is NodePath<t.Property>;
848
+ // isPureish(props?: object | null): boolean; // this is NodePath<t.Pureish>;
849
+ // isQualifiedTypeIdentifier(props?: object | null): boolean; // this is NodePath<t.QualifiedTypeIdentifier>;
850
+ // isRegExpLiteral(props?: object | null): boolean; // this is NodePath<t.RegExpLiteral>;
851
+ // isRestElement(props?: object | null): boolean; // this is NodePath<t.RestElement>;
852
+ // isReturnStatement(props?: object | null): boolean; // this is NodePath<t.ReturnStatement>;
853
+ // isScopable(props?: object | null): boolean; // this is NodePath<t.Scopable>;
854
+ // isSequenceExpression(props?: object | null): boolean; // this is NodePath<t.SequenceExpression>;
855
+ // isSpreadElement(props?: object | null): boolean; // this is NodePath<t.SpreadElement>;
856
+ // isStatement(props?: object | null): boolean; // this is NodePath<t.Statement>;
857
+ // isStringLiteral(props?: object | null): boolean; // this is NodePath<t.StringLiteral>;
858
+ // isStringLiteralTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.StringLiteralTypeAnnotation>;
859
+ // isStringTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.StringTypeAnnotation>;
860
+ // isSuper(props?: object | null): boolean; // this is NodePath<t.Super>;
861
+ // isSwitchCase(props?: object | null): boolean; // this is NodePath<t.SwitchCase>;
862
+ // isSwitchStatement(props?: object | null): boolean; // this is NodePath<t.SwitchStatement>;
863
+ // isTSAnyKeyword(props?: object | null): boolean; // this is NodePath<t.TSAnyKeyword>;
864
+ // isTSArrayType(props?: object | null): boolean; // this is NodePath<t.TSArrayType>;
865
+ // isTSAsExpression(props?: object | null): boolean; // this is NodePath<t.TSAsExpression>;
866
+ // isTSBooleanKeyword(props?: object | null): boolean; // this is NodePath<t.TSBooleanKeyword>;
867
+ // isTSCallSignatureDeclaration(props?: object | null): boolean; // this is NodePath<t.TSCallSignatureDeclaration>;
868
+ // isTSConditionalType(props?: object | null): boolean; // this is NodePath<t.TSConditionalType>;
869
+ // isTSConstructSignatureDeclaration(props?: object | null): boolean; // this is NodePath<t.TSConstructSignatureDeclaration>;
870
+ // isTSConstructorType(props?: object | null): boolean; // this is NodePath<t.TSConstructorType>;
871
+ // isTSDeclareFunction(props?: object | null): boolean; // this is NodePath<t.TSDeclareFunction>;
872
+ // isTSDeclareMethod(props?: object | null): boolean; // this is NodePath<t.TSDeclareMethod>;
873
+ // isTSEntityName(props?: object | null): boolean; // this is NodePath<t.TSEntityName>;
874
+ // isTSEnumDeclaration(props?: object | null): boolean; // this is NodePath<t.TSEnumDeclaration>;
875
+ // isTSEnumMember(props?: object | null): boolean; // this is NodePath<t.TSEnumMember>;
876
+ // isTSExportAssignment(props?: object | null): boolean; // this is NodePath<t.TSExportAssignment>;
877
+ // isTSExpressionWithTypeArguments(props?: object | null): boolean; // this is NodePath<t.TSExpressionWithTypeArguments>;
878
+ // isTSExternalModuleReference(props?: object | null): boolean; // this is NodePath<t.TSExternalModuleReference>;
879
+ // isTSFunctionType(props?: object | null): boolean; // this is NodePath<t.TSFunctionType>;
880
+ // isTSImportEqualsDeclaration(props?: object | null): boolean; // this is NodePath<t.TSImportEqualsDeclaration>;
881
+ // isTSImportType(props?: object | null): boolean; // this is NodePath<t.TSImportType>;
882
+ // isTSIndexSignature(props?: object | null): boolean; // this is NodePath<t.TSIndexSignature>;
883
+ // isTSIndexedAccessType(props?: object | null): boolean; // this is NodePath<t.TSIndexedAccessType>;
884
+ // isTSInferType(props?: object | null): boolean; // this is NodePath<t.TSInferType>;
885
+ // isTSInterfaceBody(props?: object | null): boolean; // this is NodePath<t.TSInterfaceBody>;
886
+ // isTSInterfaceDeclaration(props?: object | null): boolean; // this is NodePath<t.TSInterfaceDeclaration>;
887
+ // isTSIntersectionType(props?: object | null): boolean; // this is NodePath<t.TSIntersectionType>;
888
+ // isTSLiteralType(props?: object | null): boolean; // this is NodePath<t.TSLiteralType>;
889
+ // isTSMappedType(props?: object | null): boolean; // this is NodePath<t.TSMappedType>;
890
+ // isTSMethodSignature(props?: object | null): boolean; // this is NodePath<t.TSMethodSignature>;
891
+ // isTSModuleBlock(props?: object | null): boolean; // this is NodePath<t.TSModuleBlock>;
892
+ // isTSModuleDeclaration(props?: object | null): boolean; // this is NodePath<t.TSModuleDeclaration>;
893
+ // isTSNamespaceExportDeclaration(props?: object | null): boolean; // this is NodePath<t.TSNamespaceExportDeclaration>;
894
+ // isTSNeverKeyword(props?: object | null): boolean; // this is NodePath<t.TSNeverKeyword>;
895
+ // isTSNonNullExpression(props?: object | null): boolean; // this is NodePath<t.TSNonNullExpression>;
896
+ // isTSNullKeyword(props?: object | null): boolean; // this is NodePath<t.TSNullKeyword>;
897
+ // isTSNumberKeyword(props?: object | null): boolean; // this is NodePath<t.TSNumberKeyword>;
898
+ // isTSObjectKeyword(props?: object | null): boolean; // this is NodePath<t.TSObjectKeyword>;
899
+ // isTSOptionalType(props?: object | null): boolean; // this is NodePath<t.TSOptionalType>;
900
+ // isTSParameterProperty(props?: object | null): boolean; // this is NodePath<t.TSParameterProperty>;
901
+ // isTSParenthesizedType(props?: object | null): boolean; // this is NodePath<t.TSParenthesizedType>;
902
+ // isTSPropertySignature(props?: object | null): boolean; // this is NodePath<t.TSPropertySignature>;
903
+ // isTSQualifiedName(props?: object | null): boolean; // this is NodePath<t.TSQualifiedName>;
904
+ // isTSRestType(props?: object | null): boolean; // this is NodePath<t.TSRestType>;
905
+ // isTSStringKeyword(props?: object | null): boolean; // this is NodePath<t.TSStringKeyword>;
906
+ // isTSSymbolKeyword(props?: object | null): boolean; // this is NodePath<t.TSSymbolKeyword>;
907
+ // isTSThisType(props?: object | null): boolean; // this is NodePath<t.TSThisType>;
908
+ // isTSTupleType(props?: object | null): boolean; // this is NodePath<t.TSTupleType>;
909
+ // isTSType(props?: object | null): boolean; // this is NodePath<t.TSType>;
910
+ // isTSTypeAliasDeclaration(props?: object | null): boolean; // this is NodePath<t.TSTypeAliasDeclaration>;
911
+ // isTSTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.TSTypeAnnotation>;
912
+ // isTSTypeAssertion(props?: object | null): boolean; // this is NodePath<t.TSTypeAssertion>;
913
+ // isTSTypeElement(props?: object | null): boolean; // this is NodePath<t.TSTypeElement>;
914
+ // isTSTypeLiteral(props?: object | null): boolean; // this is NodePath<t.TSTypeLiteral>;
915
+ // isTSTypeOperator(props?: object | null): boolean; // this is NodePath<t.TSTypeOperator>;
916
+ // isTSTypeParameter(props?: object | null): boolean; // this is NodePath<t.TSTypeParameter>;
917
+ // isTSTypeParameterDeclaration(props?: object | null): boolean; // this is NodePath<t.TSTypeParameterDeclaration>;
918
+ // isTSTypeParameterInstantiation(props?: object | null): boolean; // this is NodePath<t.TSTypeParameterInstantiation>;
919
+ // isTSTypePredicate(props?: object | null): boolean; // this is NodePath<t.TSTypePredicate>;
920
+ // isTSTypeQuery(props?: object | null): boolean; // this is NodePath<t.TSTypeQuery>;
921
+ // isTSTypeReference(props?: object | null): boolean; // this is NodePath<t.TSTypeReference>;
922
+ // isTSUndefinedKeyword(props?: object | null): boolean; // this is NodePath<t.TSUndefinedKeyword>;
923
+ // isTSUnionType(props?: object | null): boolean; // this is NodePath<t.TSUnionType>;
924
+ // isTSUnknownKeyword(props?: object | null): boolean; // this is NodePath<t.TSUnknownKeyword>;
925
+ // isTSVoidKeyword(props?: object | null): boolean; // this is NodePath<t.TSVoidKeyword>;
926
+ // isTaggedTemplateExpression(props?: object | null): boolean; // this is NodePath<t.TaggedTemplateExpression>;
927
+ // isTemplateElement(props?: object | null): boolean; // this is NodePath<t.TemplateElement>;
928
+ // isTemplateLiteral(props?: object | null): boolean; // this is NodePath<t.TemplateLiteral>;
929
+ // isTerminatorless(props?: object | null): boolean; // this is NodePath<t.Terminatorless>;
930
+ // isThisExpression(props?: object | null): boolean; // this is NodePath<t.ThisExpression>;
931
+ // isThisTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.ThisTypeAnnotation>;
932
+ // isThrowStatement(props?: object | null): boolean; // this is NodePath<t.ThrowStatement>;
933
+ // isTryStatement(props?: object | null): boolean; // this is NodePath<t.TryStatement>;
934
+ // isTupleTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.TupleTypeAnnotation>;
935
+ // isTypeAlias(props?: object | null): boolean; // this is NodePath<t.TypeAlias>;
936
+ // isTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.TypeAnnotation>;
937
+ // isTypeCastExpression(props?: object | null): boolean; // this is NodePath<t.TypeCastExpression>;
938
+ // isTypeParameter(props?: object | null): boolean; // this is NodePath<t.TypeParameter>;
939
+ // isTypeParameterDeclaration(props?: object | null): boolean; // this is NodePath<t.TypeParameterDeclaration>;
940
+ // isTypeParameterInstantiation(props?: object | null): boolean; // this is NodePath<t.TypeParameterInstantiation>;
941
+ // isTypeofTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.TypeofTypeAnnotation>;
942
+ // isUnaryExpression(props?: object | null): boolean; // this is NodePath<t.UnaryExpression>;
943
+ // isUnaryLike(props?: object | null): boolean; // this is NodePath<t.UnaryLike>;
944
+ // isUnionTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.UnionTypeAnnotation>;
945
+ // isUpdateExpression(props?: object | null): boolean; // this is NodePath<t.UpdateExpression>;
946
+ // isUserWhitespacable(props?: object | null): boolean; // this is NodePath<t.UserWhitespacable>;
947
+ // isVariableDeclaration(props?: object | null): boolean; // this is NodePath<t.VariableDeclaration>;
948
+ // isVariableDeclarator(props?: object | null): boolean; // this is NodePath<t.VariableDeclarator>;
949
+ // isVariance(props?: object | null): boolean; // this is NodePath<t.Variance>;
950
+ // isVoidTypeAnnotation(props?: object | null): boolean; // this is NodePath<t.VoidTypeAnnotation>;
951
+ // isWhile(props?: object | null): boolean; // this is NodePath<t.While>;
952
+ // isWhileStatement(props?: object | null): boolean; // this is NodePath<t.WhileStatement>;
953
+ // isWithStatement(props?: object | null): boolean; // this is NodePath<t.WithStatement>;
954
+ // isYieldExpression(props?: object | null): boolean; // this is NodePath<t.YieldExpression>;
955
+ // isBindingIdentifier(props?: object | null): boolean; // this is NodePath<t.Identifier>;
956
+ // isBlockScoped(
957
+ // props?: object | null,
958
+ // ): boolean; // this is NodePath<t.FunctionDeclaration | t.ClassDeclaration | t.VariableDeclaration>;
959
+ // isGenerated(props?: object | null): boolean;
960
+ // isPure(props?: object | null): boolean;
961
+ // isReferenced(props?: object | null): boolean;
962
+ // isReferencedIdentifier(props?: object | null): boolean; // this is NodePath<t.Identifier | t.JSXIdentifier>;
963
+ // isReferencedMemberExpression(props?: object | null): boolean; // this is NodePath<t.MemberExpression>;
964
+ // isScope(props?: object | null): boolean; // this is NodePath<t.Scopable>;
965
+ // isUser(props?: object | null): boolean;
966
+ // isVar(props?: object | null): boolean; // this is NodePath<t.VariableDeclaration>;
967
+ //#endregion
968
+
969
+ //#region ------------------------- assertXXX -------------------------
970
+ // Purposely skipping all `assert` functions as Flow can't handle them.
971
+ //#endregion
972
+ }
973
+
974
+ export interface HubInterface {
975
+ getCode(): string | void;
976
+ getScope(): Scope | void;
977
+ addHelper(name: string): any;
978
+ buildError<E: Error>(node: Node, msg: string, Error: Class<E>): E;
979
+ }
980
+
981
+ declare export class Hub implements HubInterface {
982
+ constructor(): Hub;
983
+ getCode(): string | void;
984
+ getScope(): Scope | void;
985
+ addHelper(name: string): any;
986
+ buildError<E: Error>(node: Node, msg: string, Constructor: Class<E>): E;
987
+ }
988
+
989
+ export interface TraversalContext {
990
+ parentPath: NodePath<>;
991
+ scope: Scope;
992
+ state: any;
993
+ opts: any;
994
+ }
995
+
996
+ export type NodePathResult<T: Node | $ReadOnlyArray<Node>> =
997
+ T extends $ReadOnlyArray<infer TNode>
998
+ ? $ReadOnlyArray<NodePath<TNode>>
999
+ : T extends null | void
1000
+ ? void
1001
+ : T extends Node
1002
+ ? NodePath<T>
1003
+ : T;