How to use visitNode method in ts-auto-mock

Best JavaScript code snippet using ts-auto-mock

index.d.ts

Source:index.d.ts Github

copy

Full Screen

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

Full Screen

Full Screen

astToText.ts

Source:astToText.ts Github

copy

Full Screen

...106// let visitNodes: (cb: (node: Node | Node[]) => T, nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode;107// let cbNodes = cbNodeArray || cbNode;108// switch (node.kind) {109// case SyntaxKind.QualifiedName:110// return visitNode(cbNode, (<QualifiedName>node).left) ||111// visitNode(cbNode, (<QualifiedName>node).right);112// case SyntaxKind.TypeParameter:113// return visitNode(cbNode, (<TypeParameterDeclaration>node).name) ||114// visitNode(cbNode, (<TypeParameterDeclaration>node).constraint) ||115// visitNode(cbNode, (<TypeParameterDeclaration>node).expression);116// case SyntaxKind.Parameter:117// case SyntaxKind.PropertyDeclaration:118// case SyntaxKind.PropertySignature:119// case SyntaxKind.PropertyAssignment:120// case SyntaxKind.ShorthandPropertyAssignment:121// case SyntaxKind.VariableDeclaration:122// case SyntaxKind.BindingElement:123// return visitNodes(cbNodes, node.decorators) ||124// visitNodes(cbNodes, node.modifiers) ||125// visitNode(cbNode, (<VariableLikeDeclaration>node).propertyName) ||126// visitNode(cbNode, (<VariableLikeDeclaration>node).dotDotDotToken) ||127// visitNode(cbNode, (<VariableLikeDeclaration>node).name) ||128// visitNode(cbNode, (<VariableLikeDeclaration>node).questionToken) ||129// visitNode(cbNode, (<VariableLikeDeclaration>node).type) ||130// visitNode(cbNode, (<VariableLikeDeclaration>node).initializer);131// case SyntaxKind.FunctionType:132// case SyntaxKind.ConstructorType:133// case SyntaxKind.CallSignature:134// case SyntaxKind.ConstructSignature:135// case SyntaxKind.IndexSignature:136// return visitNodes(cbNodes, node.decorators) ||137// visitNodes(cbNodes, node.modifiers) ||138// visitNodes(cbNodes, (<SignatureDeclaration>node).typeParameters) ||139// visitNodes(cbNodes, (<SignatureDeclaration>node).parameters) ||140// visitNode(cbNode, (<SignatureDeclaration>node).type);141// case SyntaxKind.MethodDeclaration:142// case SyntaxKind.MethodSignature:143// case SyntaxKind.Constructor:144// case SyntaxKind.GetAccessor:145// case SyntaxKind.SetAccessor:146// case SyntaxKind.FunctionExpression:147// case SyntaxKind.FunctionDeclaration:148// case SyntaxKind.ArrowFunction:149// return visitNodes(cbNodes, node.decorators) ||150// visitNodes(cbNodes, node.modifiers) ||151// visitNode(cbNode, (<FunctionLikeDeclaration>node).asteriskToken) ||152// visitNode(cbNode, (<FunctionLikeDeclaration>node).name) ||153// visitNode(cbNode, (<FunctionLikeDeclaration>node).questionToken) ||154// visitNodes(cbNodes, (<FunctionLikeDeclaration>node).typeParameters) ||155// visitNodes(cbNodes, (<FunctionLikeDeclaration>node).parameters) ||156// visitNode(cbNode, (<FunctionLikeDeclaration>node).type) ||157// visitNode(cbNode, (<ArrowFunction>node).equalsGreaterThanToken) ||158// visitNode(cbNode, (<FunctionLikeDeclaration>node).body);159// case SyntaxKind.TypeReference:160// return visitNode(cbNode, (<TypeReferenceNode>node).typeName) ||161// visitNodes(cbNodes, (<TypeReferenceNode>node).typeArguments);162// case SyntaxKind.TypeQuery:163// return visitNode(cbNode, (<TypeQueryNode>node).exprName);164// case SyntaxKind.TypeLiteral:165// return visitNodes(cbNodes, (<TypeLiteralNode>node).members);166// case SyntaxKind.ArrayType:167// return visitNode(cbNode, (<ArrayTypeNode>node).elementType);168// case SyntaxKind.TupleType:169// return visitNodes(cbNodes, (<TupleTypeNode>node).elementTypes);170// case SyntaxKind.UnionType:171// return visitNodes(cbNodes, (<UnionTypeNode>node).types);172// case SyntaxKind.ParenthesizedType:173// return visitNode(cbNode, (<ParenthesizedTypeNode>node).type);174// case SyntaxKind.ObjectBindingPattern:175// case SyntaxKind.ArrayBindingPattern:176// return visitNodes(cbNodes, (<BindingPattern>node).elements);177// case SyntaxKind.ArrayLiteralExpression:178// return visitNodes(cbNodes, (<ArrayLiteralExpression>node).elements);179// case SyntaxKind.ObjectLiteralExpression:180// return visitNodes(cbNodes, (<ObjectLiteralExpression>node).properties);181// case SyntaxKind.PropertyAccessExpression:182// return visitNode(cbNode, (<PropertyAccessExpression>node).expression) ||183// visitNode(cbNode, (<PropertyAccessExpression>node).dotToken) ||184// visitNode(cbNode, (<PropertyAccessExpression>node).name);185// case SyntaxKind.ElementAccessExpression:186// return visitNode(cbNode, (<ElementAccessExpression>node).expression) ||187// visitNode(cbNode, (<ElementAccessExpression>node).argumentExpression);188// case SyntaxKind.CallExpression:189// case SyntaxKind.NewExpression:190// return visitNode(cbNode, (<CallExpression>node).expression) ||191// visitNodes(cbNodes, (<CallExpression>node).typeArguments) ||192// visitNodes(cbNodes, (<CallExpression>node).arguments);193// case SyntaxKind.TaggedTemplateExpression:194// return visitNode(cbNode, (<TaggedTemplateExpression>node).tag) ||195// visitNode(cbNode, (<TaggedTemplateExpression>node).template);196// case SyntaxKind.TypeAssertionExpression:197// return visitNode(cbNode, (<TypeAssertion>node).type) ||198// visitNode(cbNode, (<TypeAssertion>node).expression);199// case SyntaxKind.ParenthesizedExpression:200// return visitNode(cbNode, (<ParenthesizedExpression>node).expression);201// case SyntaxKind.DeleteExpression:202// return visitNode(cbNode, (<DeleteExpression>node).expression);203// case SyntaxKind.TypeOfExpression:204// return visitNode(cbNode, (<TypeOfExpression>node).expression);205// case SyntaxKind.VoidExpression:206// return visitNode(cbNode, (<VoidExpression>node).expression);207// case SyntaxKind.PrefixUnaryExpression:208// return visitNode(cbNode, (<PrefixUnaryExpression>node).operand);209// case SyntaxKind.YieldExpression:210// return visitNode(cbNode, (<YieldExpression>node).asteriskToken) ||211// visitNode(cbNode, (<YieldExpression>node).expression);212// case SyntaxKind.PostfixUnaryExpression:213// return visitNode(cbNode, (<PostfixUnaryExpression>node).operand);214// case SyntaxKind.BinaryExpression:215// return visitNode(cbNode, (<BinaryExpression>node).left) ||216// visitNode(cbNode, (<BinaryExpression>node).operatorToken) ||217// visitNode(cbNode, (<BinaryExpression>node).right);218// case SyntaxKind.ConditionalExpression:219// return visitNode(cbNode, (<ConditionalExpression>node).condition) ||220// visitNode(cbNode, (<ConditionalExpression>node).questionToken) ||221// visitNode(cbNode, (<ConditionalExpression>node).whenTrue) ||222// visitNode(cbNode, (<ConditionalExpression>node).colonToken) ||223// visitNode(cbNode, (<ConditionalExpression>node).whenFalse);224// case SyntaxKind.SpreadElementExpression:225// return visitNode(cbNode, (<SpreadElementExpression>node).expression);226// case SyntaxKind.Block:227// case SyntaxKind.ModuleBlock:228// return visitNodes(cbNodes, (<Block>node).statements);229// case SyntaxKind.SourceFile:230// return visitNodes(cbNodes, (<SourceFile>node).statements) ||231// visitNode(cbNode, (<SourceFile>node).endOfFileToken);232// case SyntaxKind.VariableStatement:233// return visitNodes(cbNodes, node.decorators) ||234// visitNodes(cbNodes, node.modifiers) ||235// visitNode(cbNode, (<VariableStatement>node).declarationList);236// case SyntaxKind.VariableDeclarationList:237// return visitNodes(cbNodes, (<VariableDeclarationList>node).declarations);238// case SyntaxKind.ExpressionStatement:239// return visitNode(cbNode, (<ExpressionStatement>node).expression);240// case SyntaxKind.IfStatement:241// return visitNode(cbNode, (<IfStatement>node).expression) ||242// visitNode(cbNode, (<IfStatement>node).thenStatement) ||243// visitNode(cbNode, (<IfStatement>node).elseStatement);244// case SyntaxKind.DoStatement:245// return visitNode(cbNode, (<DoStatement>node).statement) ||246// visitNode(cbNode, (<DoStatement>node).expression);247// case SyntaxKind.WhileStatement:248// return visitNode(cbNode, (<WhileStatement>node).expression) ||249// visitNode(cbNode, (<WhileStatement>node).statement);250// case SyntaxKind.ForStatement:251// return visitNode(cbNode, (<ForStatement>node).initializer) ||252// visitNode(cbNode, (<ForStatement>node).condition) ||253// visitNode(cbNode, (<ForStatement>node).iterator) ||254// visitNode(cbNode, (<ForStatement>node).statement);255// case SyntaxKind.ForInStatement:256// return visitNode(cbNode, (<ForInStatement>node).initializer) ||257// visitNode(cbNode, (<ForInStatement>node).expression) ||258// visitNode(cbNode, (<ForInStatement>node).statement);259// case SyntaxKind.ForOfStatement:260// return visitNode(cbNode, (<ForOfStatement>node).initializer) ||261// visitNode(cbNode, (<ForOfStatement>node).expression) ||262// visitNode(cbNode, (<ForOfStatement>node).statement);263// case SyntaxKind.ContinueStatement:264// case SyntaxKind.BreakStatement:265// return visitNode(cbNode, (<BreakOrContinueStatement>node).label);266// case SyntaxKind.ReturnStatement:267// return visitNode(cbNode, (<ReturnStatement>node).expression);268// case SyntaxKind.WithStatement:269// return visitNode(cbNode, (<WithStatement>node).expression) ||270// visitNode(cbNode, (<WithStatement>node).statement);271// case SyntaxKind.SwitchStatement:272// return visitNode(cbNode, (<SwitchStatement>node).expression) ||273// visitNode(cbNode, (<SwitchStatement>node).caseBlock);274// case SyntaxKind.CaseBlock:275// return visitNodes(cbNodes, (<CaseBlock>node).clauses);276// case SyntaxKind.CaseClause:277// return visitNode(cbNode, (<CaseClause>node).expression) ||278// visitNodes(cbNodes, (<CaseClause>node).statements);279// case SyntaxKind.DefaultClause:280// return visitNodes(cbNodes, (<DefaultClause>node).statements);281// case SyntaxKind.LabeledStatement:282// return visitNode(cbNode, (<LabeledStatement>node).label) ||283// visitNode(cbNode, (<LabeledStatement>node).statement);284// case SyntaxKind.ThrowStatement:285// return visitNode(cbNode, (<ThrowStatement>node).expression);286// case SyntaxKind.TryStatement:287// return visitNode(cbNode, (<TryStatement>node).tryBlock) ||288// visitNode(cbNode, (<TryStatement>node).catchClause) ||289// visitNode(cbNode, (<TryStatement>node).finallyBlock);290// case SyntaxKind.CatchClause:291// return visitNode(cbNode, (<CatchClause>node).variableDeclaration) ||292// visitNode(cbNode, (<CatchClause>node).block);293// case SyntaxKind.Decorator:294// return visitNode(cbNode, (<Decorator>node).expression);295// case SyntaxKind.ClassDeclaration:296// case SyntaxKind.ClassExpression:297// return visitNodes(cbNodes, node.decorators) ||298// visitNodes(cbNodes, node.modifiers) ||299// visitNode(cbNode, (<ClassLikeDeclaration>node).name) ||300// visitNodes(cbNodes, (<ClassLikeDeclaration>node).typeParameters) ||301// visitNodes(cbNodes, (<ClassLikeDeclaration>node).heritageClauses) ||302// visitNodes(cbNodes, (<ClassLikeDeclaration>node).members);303// case SyntaxKind.InterfaceDeclaration:304// return visitNodes(cbNodes, node.decorators) ||305// visitNodes(cbNodes, node.modifiers) ||306// visitNode(cbNode, (<InterfaceDeclaration>node).name) ||307// visitNodes(cbNodes, (<InterfaceDeclaration>node).typeParameters) ||308// visitNodes(cbNodes, (<ClassDeclaration>node).heritageClauses) ||309// visitNodes(cbNodes, (<InterfaceDeclaration>node).members);310// case SyntaxKind.TypeAliasDeclaration:311// return visitNodes(cbNodes, node.decorators) ||312// visitNodes(cbNodes, node.modifiers) ||313// visitNode(cbNode, (<TypeAliasDeclaration>node).name) ||314// visitNode(cbNode, (<TypeAliasDeclaration>node).type);315// case SyntaxKind.EnumDeclaration:316// return visitNodes(cbNodes, node.decorators) ||317// visitNodes(cbNodes, node.modifiers) ||318// visitNode(cbNode, (<EnumDeclaration>node).name) ||319// visitNodes(cbNodes, (<EnumDeclaration>node).members);320// case SyntaxKind.EnumMember:321// return visitNode(cbNode, (<EnumMember>node).name) ||322// visitNode(cbNode, (<EnumMember>node).initializer);323// case SyntaxKind.ModuleDeclaration:324// return visitNodes(cbNodes, node.decorators) ||325// visitNodes(cbNodes, node.modifiers) ||326// visitNode(cbNode, (<ModuleDeclaration>node).name) ||327// visitNode(cbNode, (<ModuleDeclaration>node).body);328// case SyntaxKind.ImportEqualsDeclaration:329// return visitNodes(cbNodes, node.decorators) ||330// visitNodes(cbNodes, node.modifiers) ||331// visitNode(cbNode, (<ImportEqualsDeclaration>node).name) ||332// visitNode(cbNode, (<ImportEqualsDeclaration>node).moduleReference);333// case SyntaxKind.ImportDeclaration:334// return visitNodes(cbNodes, node.decorators) ||335// visitNodes(cbNodes, node.modifiers) ||336// visitNode(cbNode, (<ImportDeclaration>node).importClause) ||337// visitNode(cbNode, (<ImportDeclaration>node).moduleSpecifier);338// case SyntaxKind.ImportClause:339// return visitNode(cbNode, (<ImportClause>node).name) ||340// visitNode(cbNode, (<ImportClause>node).namedBindings);341// case SyntaxKind.NamespaceImport:342// return visitNode(cbNode, (<NamespaceImport>node).name);343// case SyntaxKind.NamedImports:344// case SyntaxKind.NamedExports:345// return visitNodes(cbNodes, (<NamedImportsOrExports>node).elements);346// case SyntaxKind.ExportDeclaration:347// return visitNodes(cbNodes, node.decorators) ||348// visitNodes(cbNodes, node.modifiers) ||349// visitNode(cbNode, (<ExportDeclaration>node).exportClause) ||350// visitNode(cbNode, (<ExportDeclaration>node).moduleSpecifier);351// case SyntaxKind.ImportSpecifier:352// case SyntaxKind.ExportSpecifier:353// return visitNode(cbNode, (<ImportOrExportSpecifier>node).propertyName) ||354// visitNode(cbNode, (<ImportOrExportSpecifier>node).name);355// case SyntaxKind.ExportAssignment:356// return visitNodes(cbNodes, node.decorators) ||357// visitNodes(cbNodes, node.modifiers) ||358// visitNode(cbNode, (<ExportAssignment>node).expression) ||359// visitNode(cbNode, (<ExportAssignment>node).type);360// case SyntaxKind.TemplateExpression:361// return visitNode(cbNode, (<TemplateExpression>node).head) || visitNodes(cbNodes, (<TemplateExpression>node).templateSpans);362// case SyntaxKind.TemplateSpan:363// return visitNode(cbNode, (<TemplateSpan>node).expression) || visitNode(cbNode, (<TemplateSpan>node).literal);364// case SyntaxKind.ComputedPropertyName:365// return visitNode(cbNode, (<ComputedPropertyName>node).expression);366// case SyntaxKind.HeritageClause:367// return visitNodes(cbNodes, (<HeritageClause>node).types);368// case SyntaxKind.HeritageClauseElement:369// return visitNode(cbNode, (<HeritageClauseElement>node).expression) ||370// visitNodes(cbNodes, (<HeritageClauseElement>node).typeArguments);371// case SyntaxKind.ExternalModuleReference:372// return visitNode(cbNode, (<ExternalModuleReference>node).expression);373// case SyntaxKind.MissingDeclaration:374// return visitNodes(cbNodes, node.decorators);375// }...

Full Screen

Full Screen

babel-7.d.ts

Source:babel-7.d.ts Github

copy

Full Screen

1// Babel 7 doesn't have typings yet. These are minimal and temporary2declare module '@babel/core';3declare module '@babel/plugin-syntax-import-meta';4declare module '@babel/plugin-syntax-dynamic-import';5declare module '@babel/helper-plugin-utils';6declare module '@babel/template';7declare module '@babel/traverse' {8 import * as t from 'babel-types';9 export type Node = t.Node;10 export class Scope {11 constructor(path: NodePath, parentScope?: Scope);12 path: NodePath;13 block: Node;14 parentBlock: Node;15 parent: Scope;16 // hub: Hub;17 bindings: {[name: string]: Binding;};18 /** Generate a unique identifier and add it to the current scope. */19 generateDeclaredUidIdentifier(name?: string): t.Identifier;20 /** Generate a unique identifier. */21 generateUidIdentifier(name?: string): t.Identifier;22 /** Generate a unique `_id1` binding. */23 generateUid(name?: string): string;24 /** Walks the scope tree and gathers **all** bindings. */25 getAllBindings(...kinds: string[]): object;26 }27 export class Binding {28 constructor(opts: {29 existing: Binding; identifier: t.Identifier; scope: Scope; path: NodePath;30 kind: 'var' | 'let' | 'const';31 });32 identifier: t.Identifier;33 scope: Scope;34 path: NodePath;35 kind: 'var'|'let'|'const'|'module';36 referenced: boolean;37 references: number;38 referencePaths: NodePath[];39 constant: boolean;40 constantViolations: NodePath[];41 }42 export class NodePath<T = Node> {43 node: T;44 scope: Scope;45 traverse(visitor: Visitor, state?: any): void;46 // ------------------------- replacement -------------------------47 /**48 * Replace a node with an array of multiple. This method performs the49 * following steps:50 *51 * - Inherit the comments of first provided node with that of the current52 * node.53 * - Insert the provided nodes after the current node.54 * - Remove the current node.55 */56 replaceWithMultiple(nodes: Node[]): void;57 /**58 * Parse a string as an expression and replace the current node with the59 * result.60 *61 * NOTE: This is typically not a good idea to use. Building source strings62 * when transforming ASTs is an antipattern and SHOULD NOT be encouraged.63 * Even if it's easier to use, your transforms will be extremely brittle.64 */65 replaceWithSourceString(replacement: any): void;66 /** Replace the current node with another. */67 replaceWith(replacement: Node|NodePath): void;68 /**69 * This method takes an array of statements nodes and then explodes it70 * into expressions. This method retains completion records which is71 * extremely important to retain original semantics.72 */73 replaceExpressionWithStatements(nodes: Node[]): Node;74 replaceInline(nodes: Node|Node[]): void;75 }76 // The Visitor has to be generic because babel binds `this` for each property.77 // `this` is usually used in babel plugins to pass plugin state from78 // `pre` -> `visitor` -> `post`. An example of this can be seen in the79 // official babel handbook:80 // https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#-pre-and-post-in-plugins81 export interface Visitor<S = Node> extends VisitNodeObject<Node> {82 ArrayExpression?: VisitNode<S, t.ArrayExpression>;83 AssignmentExpression?: VisitNode<S, t.AssignmentExpression>;84 LVal?: VisitNode<S, t.LVal>;85 Expression?: VisitNode<S, t.Expression>;86 BinaryExpression?: VisitNode<S, t.BinaryExpression>;87 Directive?: VisitNode<S, t.Directive>;88 DirectiveLiteral?: VisitNode<S, t.DirectiveLiteral>;89 BlockStatement?: VisitNode<S, t.BlockStatement>;90 BreakStatement?: VisitNode<S, t.BreakStatement>;91 Identifier?: VisitNode<S, t.Identifier>;92 CallExpression?: VisitNode<S, t.CallExpression>;93 CatchClause?: VisitNode<S, t.CatchClause>;94 ConditionalExpression?: VisitNode<S, t.ConditionalExpression>;95 ContinueStatement?: VisitNode<S, t.ContinueStatement>;96 DebuggerStatement?: VisitNode<S, t.DebuggerStatement>;97 DoWhileStatement?: VisitNode<S, t.DoWhileStatement>;98 Statement?: VisitNode<S, t.Statement>;99 EmptyStatement?: VisitNode<S, t.EmptyStatement>;100 ExpressionStatement?: VisitNode<S, t.ExpressionStatement>;101 File?: VisitNode<S, t.File>;102 Program?: VisitNode<S, t.Program>;103 ForInStatement?: VisitNode<S, t.ForInStatement>;104 VariableDeclaration?: VisitNode<S, t.VariableDeclaration>;105 ForStatement?: VisitNode<S, t.ForStatement>;106 FunctionDeclaration?: VisitNode<S, t.FunctionDeclaration>;107 FunctionExpression?: VisitNode<S, t.FunctionExpression>;108 IfStatement?: VisitNode<S, t.IfStatement>;109 LabeledStatement?: VisitNode<S, t.LabeledStatement>;110 StringLiteral?: VisitNode<S, t.StringLiteral>;111 NumericLiteral?: VisitNode<S, t.NumericLiteral>;112 NullLiteral?: VisitNode<S, t.NullLiteral>;113 BooleanLiteral?: VisitNode<S, t.BooleanLiteral>;114 RegExpLiteral?: VisitNode<S, t.RegExpLiteral>;115 LogicalExpression?: VisitNode<S, t.LogicalExpression>;116 MemberExpression?: VisitNode<S, t.MemberExpression>;117 NewExpression?: VisitNode<S, t.NewExpression>;118 ObjectExpression?: VisitNode<S, t.ObjectExpression>;119 ObjectMethod?: VisitNode<S, t.ObjectMethod>;120 ObjectProperty?: VisitNode<S, t.ObjectProperty>;121 RestElement?: VisitNode<S, t.RestElement>;122 ReturnStatement?: VisitNode<S, t.ReturnStatement>;123 SequenceExpression?: VisitNode<S, t.SequenceExpression>;124 SwitchCase?: VisitNode<S, t.SwitchCase>;125 SwitchStatement?: VisitNode<S, t.SwitchStatement>;126 ThisExpression?: VisitNode<S, t.ThisExpression>;127 ThrowStatement?: VisitNode<S, t.ThrowStatement>;128 TryStatement?: VisitNode<S, t.TryStatement>;129 UnaryExpression?: VisitNode<S, t.UnaryExpression>;130 UpdateExpression?: VisitNode<S, t.UpdateExpression>;131 VariableDeclarator?: VisitNode<S, t.VariableDeclarator>;132 WhileStatement?: VisitNode<S, t.WhileStatement>;133 WithStatement?: VisitNode<S, t.WithStatement>;134 AssignmentPattern?: VisitNode<S, t.AssignmentPattern>;135 ArrayPattern?: VisitNode<S, t.ArrayPattern>;136 ArrowFunctionExpression?: VisitNode<S, t.ArrowFunctionExpression>;137 ClassBody?: VisitNode<S, t.ClassBody>;138 ClassDeclaration?: VisitNode<S, t.ClassDeclaration>;139 ClassExpression?: VisitNode<S, t.ClassExpression>;140 ExportAllDeclaration?: VisitNode<S, t.ExportAllDeclaration>;141 ExportDefaultDeclaration?: VisitNode<S, t.ExportDefaultDeclaration>;142 ExportNamedDeclaration?: VisitNode<S, t.ExportNamedDeclaration>;143 Declaration?: VisitNode<S, t.Declaration>;144 ExportSpecifier?: VisitNode<S, t.ExportSpecifier>;145 ForOfStatement?: VisitNode<S, t.ForOfStatement>;146 ImportDeclaration?: VisitNode<S, t.ImportDeclaration>;147 ImportDefaultSpecifier?: VisitNode<S, t.ImportDefaultSpecifier>;148 ImportNamespaceSpecifier?: VisitNode<S, t.ImportNamespaceSpecifier>;149 ImportSpecifier?: VisitNode<S, t.ImportSpecifier>;150 MetaProperty?: VisitNode<S, t.MetaProperty>;151 ClassMethod?: VisitNode<S, t.ClassMethod>;152 ObjectPattern?: VisitNode<S, t.ObjectPattern>;153 SpreadElement?: VisitNode<S, t.SpreadElement>;154 Super?: VisitNode<S, t.Super>;155 TaggedTemplateExpression?: VisitNode<S, t.TaggedTemplateExpression>;156 TemplateLiteral?: VisitNode<S, t.TemplateLiteral>;157 TemplateElement?: VisitNode<S, t.TemplateElement>;158 YieldExpression?: VisitNode<S, t.YieldExpression>;159 AnyTypeAnnotation?: VisitNode<S, t.AnyTypeAnnotation>;160 ArrayTypeAnnotation?: VisitNode<S, t.ArrayTypeAnnotation>;161 BooleanTypeAnnotation?: VisitNode<S, t.BooleanTypeAnnotation>;162 BooleanLiteralTypeAnnotation?: VisitNode<S, t.BooleanLiteralTypeAnnotation>;163 NullLiteralTypeAnnotation?: VisitNode<S, t.NullLiteralTypeAnnotation>;164 ClassImplements?: VisitNode<S, t.ClassImplements>;165 ClassProperty?: VisitNode<S, t.ClassProperty>;166 DeclareClass?: VisitNode<S, t.DeclareClass>;167 DeclareFunction?: VisitNode<S, t.DeclareFunction>;168 DeclareInterface?: VisitNode<S, t.DeclareInterface>;169 DeclareModule?: VisitNode<S, t.DeclareModule>;170 DeclareTypeAlias?: VisitNode<S, t.DeclareTypeAlias>;171 DeclareVariable?: VisitNode<S, t.DeclareVariable>;172 ExistentialTypeParam?: VisitNode<S, t.ExistentialTypeParam>;173 FunctionTypeAnnotation?: VisitNode<S, t.FunctionTypeAnnotation>;174 FunctionTypeParam?: VisitNode<S, t.FunctionTypeParam>;175 GenericTypeAnnotation?: VisitNode<S, t.GenericTypeAnnotation>;176 InterfaceExtends?: VisitNode<S, t.InterfaceExtends>;177 InterfaceDeclaration?: VisitNode<S, t.InterfaceDeclaration>;178 IntersectionTypeAnnotation?: VisitNode<S, t.IntersectionTypeAnnotation>;179 MixedTypeAnnotation?: VisitNode<S, t.MixedTypeAnnotation>;180 NullableTypeAnnotation?: VisitNode<S, t.NullableTypeAnnotation>;181 NumericLiteralTypeAnnotation?: VisitNode<S, t.NumericLiteralTypeAnnotation>;182 NumberTypeAnnotation?: VisitNode<S, t.NumberTypeAnnotation>;183 StringLiteralTypeAnnotation?: VisitNode<S, t.StringLiteralTypeAnnotation>;184 StringTypeAnnotation?: VisitNode<S, t.StringTypeAnnotation>;185 ThisTypeAnnotation?: VisitNode<S, t.ThisTypeAnnotation>;186 TupleTypeAnnotation?: VisitNode<S, t.TupleTypeAnnotation>;187 TypeofTypeAnnotation?: VisitNode<S, t.TypeofTypeAnnotation>;188 TypeAlias?: VisitNode<S, t.TypeAlias>;189 TypeAnnotation?: VisitNode<S, t.TypeAnnotation>;190 TypeCastExpression?: VisitNode<S, t.TypeCastExpression>;191 TypeParameterDeclaration?: VisitNode<S, t.TypeParameterDeclaration>;192 TypeParameterInstantiation?: VisitNode<S, t.TypeParameterInstantiation>;193 ObjectTypeAnnotation?: VisitNode<S, t.ObjectTypeAnnotation>;194 ObjectTypeCallProperty?: VisitNode<S, t.ObjectTypeCallProperty>;195 ObjectTypeIndexer?: VisitNode<S, t.ObjectTypeIndexer>;196 ObjectTypeProperty?: VisitNode<S, t.ObjectTypeProperty>;197 QualifiedTypeIdentifier?: VisitNode<S, t.QualifiedTypeIdentifier>;198 UnionTypeAnnotation?: VisitNode<S, t.UnionTypeAnnotation>;199 VoidTypeAnnotation?: VisitNode<S, t.VoidTypeAnnotation>;200 JSXAttribute?: VisitNode<S, t.JSXAttribute>;201 JSXIdentifier?: VisitNode<S, t.JSXIdentifier>;202 JSXNamespacedName?: VisitNode<S, t.JSXNamespacedName>;203 JSXElement?: VisitNode<S, t.JSXElement>;204 JSXExpressionContainer?: VisitNode<S, t.JSXExpressionContainer>;205 JSXClosingElement?: VisitNode<S, t.JSXClosingElement>;206 JSXMemberExpression?: VisitNode<S, t.JSXMemberExpression>;207 JSXOpeningElement?: VisitNode<S, t.JSXOpeningElement>;208 JSXEmptyExpression?: VisitNode<S, t.JSXEmptyExpression>;209 JSXSpreadAttribute?: VisitNode<S, t.JSXSpreadAttribute>;210 JSXText?: VisitNode<S, t.JSXText>;211 Noop?: VisitNode<S, t.Noop>;212 ParenthesizedExpression?: VisitNode<S, t.ParenthesizedExpression>;213 AwaitExpression?: VisitNode<S, t.AwaitExpression>;214 BindExpression?: VisitNode<S, t.BindExpression>;215 Decorator?: VisitNode<S, t.Decorator>;216 DoExpression?: VisitNode<S, t.DoExpression>;217 ExportDefaultSpecifier?: VisitNode<S, t.ExportDefaultSpecifier>;218 ExportNamespaceSpecifier?: VisitNode<S, t.ExportNamespaceSpecifier>;219 RestProperty?: VisitNode<S, t.RestProperty>;220 SpreadProperty?: VisitNode<S, t.SpreadProperty>;221 Binary?: VisitNode<S, t.Binary>;222 Scopable?: VisitNode<S, t.Scopable>;223 BlockParent?: VisitNode<S, t.BlockParent>;224 Block?: VisitNode<S, t.Block>;225 Terminatorless?: VisitNode<S, t.Terminatorless>;226 CompletionStatement?: VisitNode<S, t.CompletionStatement>;227 Conditional?: VisitNode<S, t.Conditional>;228 Loop?: VisitNode<S, t.Loop>;229 While?: VisitNode<S, t.While>;230 ExpressionWrapper?: VisitNode<S, t.ExpressionWrapper>;231 For?: VisitNode<S, t.For>;232 ForXStatement?: VisitNode<S, t.ForXStatement>;233 Function?: VisitNode<S, t.Function>;234 FunctionParent?: VisitNode<S, t.FunctionParent>;235 Pureish?: VisitNode<S, t.Pureish>;236 Literal?: VisitNode<S, t.Literal>;237 Immutable?: VisitNode<S, t.Immutable>;238 UserWhitespacable?: VisitNode<S, t.UserWhitespacable>;239 Method?: VisitNode<S, t.Method>;240 ObjectMember?: VisitNode<S, t.ObjectMember>;241 Property?: VisitNode<S, t.Property>;242 UnaryLike?: VisitNode<S, t.UnaryLike>;243 Pattern?: VisitNode<S, t.Pattern>;244 Class?: VisitNode<S, t.Class>;245 ModuleDeclaration?: VisitNode<S, t.ModuleDeclaration>;246 ExportDeclaration?: VisitNode<S, t.ExportDeclaration>;247 ModuleSpecifier?: VisitNode<S, t.ModuleSpecifier>;248 Flow?: VisitNode<S, t.Flow>;249 FlowBaseAnnotation?: VisitNode<S, t.FlowBaseAnnotation>;250 FlowDeclaration?: VisitNode<S, t.FlowDeclaration>;251 JSX?: VisitNode<S, t.JSX>;252 Scope?: VisitNode<S, t.Scopable>;253 }254 export type VisitNode<T, P> = VisitNodeFunction<T, P>|VisitNodeObject<T>;255 export type VisitNodeFunction<T, P> =256 (this: T, path: NodePath<P>, state: any) => void;257 export interface VisitNodeObject<T> {258 enter?(path: NodePath<T>, state: any): void;259 exit?(path: NodePath<T>, state: any): void;260 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import * as ts from 'typescript';2import {visitNode} from 'ts-auto-mock/visitor';3const sourceFile = ts.createSourceFile(4 `import {MyInterface} from './test2';5 const test: MyInterface = {6 };`,7);8visitNode(sourceFile);9export interface MyInterface {10 test: string;11}12import {MyInterface} from './test2';13export const test: MyInterface = {14};15import * as ts from 'typescript';16import {visitNode} from 'ts-auto-mock/visitor';17const sourceFile = ts.createSourceFile(18 `import {MyInterface} from './test2';19 const test: MyInterface = {20 };`,21);22const visitor: ts.Visitor = (node: ts.Node): ts.VisitResult<ts.Node> => {23 if (ts.isImportDeclaration(node)) {24 return undefined;25 }26 return node;27};28visitNode(sourceFile, visitor);29const test: MyInterface = {30};

Full Screen

Using AI Code Generation

copy

Full Screen

1import { visitNode } from 'ts-auto-mock/visitor';2import { createSourceFile } from 'typescript';3const sourceFile = createSourceFile('test1.ts', `4 interface Foo {5 a: string;6 b: number;7 }8 const foo: Foo = {9 }10`, ts.ScriptTarget.ES2015, true, ts.ScriptKind.TS);11const visitor = (node: ts.Node) => {12 if (ts.isPropertyAssignment(node)) {13 console.log(node.name);14 }15};16visitNode(sourceFile, visitor);17import { visitNode } from 'ts-auto-mock/visitor';18import { createSourceFile } from 'typescript';19const sourceFile = createSourceFile('test2.ts', `20 interface Foo {21 a: string;22 b: number;23 }24 const foo: Foo = {25 }26`, ts.ScriptTarget.ES2015, true, ts.ScriptKind.TS);27const visitor = (node: ts.Node) => {28 if (ts.isPropertyAssignment(node)) {29 console.log(node.name);30 }31};32visitNode(sourceFile, visitor);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { visitNode } from 'ts-auto-mock/visitor';2import { ts } from 'ts-auto-mock';3const sourceFile = ts.createSourceFile(4 import { Foo } from './test2';5 const foo = new Foo();6);7visitNode(sourceFile, (node) => {8 if (ts.isImportDeclaration(node)) {9 }10});11export class Foo {12 public bar: string;13}14{15 "compilerOptions": {16 },17}18import { visitNode } from 'ts-auto-mock/visitor';19import { ts } from 'ts-auto-mock';20const sourceFile = ts.createSourceFile(21 import { Foo } from './test2';22 const foo = new Foo();23);24visitNode(sourceFile, (node) => {25 if (ts.isImportDeclaration(node)) {26 }27});28The above code doesn't work as expected. I am not able to get the import declaration node in the visitor. I am not sure if I

Full Screen

Using AI Code Generation

copy

Full Screen

1import { visitNode } from 'ts-auto-mock/visitor';2import { createMock } from 'ts-auto-mock';3describe('test1', () => {4 it('should work', () => {5 const mockInterface = createMock<Interface1>();6 visitNode(mockInterface);7 });8});9import { visitNode } from 'ts-auto-mock/visitor';10import { createMock } from 'ts-auto-mock';11describe('test2', () => {12 it('should work', () => {13 const mockInterface = createMock<Interface1>();14 visitNode(mockInterface);15 });16});17"paths": {18 }19"paths": {20 }21"paths": {22 }23"paths": {24 }25"paths": {26 }27"paths": {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { visitNode } = require('ts-auto-mock/visitor');2const { createMock } = require('ts-auto-mock');3const mock = createMock('test1.ts', 'MyInterface');4console.log(mock);5const { visitNode } = require('ts-auto-mock/visitor');6const { createMock } = require('ts-auto-mock');7const mock = createMock('test2.ts', 'MyInterface');8console.log(mock);9const { visitNode } = require('ts-auto-mock/visitor');10const { createMock } = require('ts-auto-mock');11const mock = createMock('test3.ts', 'MyInterface');12console.log(mock);13export interface ICustomType {14}15export function isCustomType(obj: any): obj is ICustomType {16 return obj && obj.type && obj.data;17}18export function isCustomType(obj: any): obj is ICustomType {19 return obj && obj.type && obj.data;20}21if(isCustomType(obj)) {22}

Full Screen

Using AI Code Generation

copy

Full Screen

1import {visitNode} from 'ts-auto-mock/visitor';2import {ts} from 'ts-auto-mock';3import {createMock} from 'ts-auto-mock';4const mockObj = createMock<MyClass>();5const type = mockObj.getType();6const symbol = mockObj.getSymbol();7const typeChecker = mockObj.getTypeChecker();8const node = mockObj.getNode();9const sourceFile = mockObj.getSourceFile();10const name = mockObj.getName();11const typeArguments = mockObj.getTypeArguments();12const parent = mockObj.getParent();13const parentType = mockObj.getParentType();14const parentSymbol = mockObj.getParentSymbol();15const parentTypeChecker = mockObj.getParentTypeChecker();16const parentNode = mockObj.getParentNode();17const parentSourceFile = mockObj.getParentSourceFile();18const parentName = mockObj.getParentName();19const parentTypeArguments = mockObj.getParentTypeArguments();20const parentParent = mockObj.getParentParent();21const parentParentType = mockObj.getParentParentType();22const parentParentSymbol = mockObj.getParentParentSymbol();23const parentParentTypeChecker = mockObj.getParentParentTypeChecker();24const parentParentNode = mockObj.getParentParentNode();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ts-auto-mock automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful