@stylexjs/babel-plugin 0.16.1 → 0.16.3

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