UNPKG

storybook

Version:

Storybook: Develop, document, and test UI components in isolation

910 lines (909 loc) • 128 kB
import { $ as DeclareModuleExports, $i as TSTypeParameter, $n as ObjectExpression, $r as TSBooleanKeyword, $t as IfStatement, A as ClassBody, Aa as UnionTypeAnnotation, Ai as TSNeverKeyword, An as LVal, Ar as RegexLiteral$1, At as ExportSpecifier, B as CompletionStatement, Ba as WithStatement, Bi as TSRestType, Bn as ModuleDeclaration, Br as StaticBlock, Bt as For, C as BooleanLiteralTypeAnnotation, Ca as TypeParameter, Ci as TSLiteralType, Cn as JSXMemberExpression, Cr as PrivateName, Ct as ExistsTypeAnnotation, D as CatchClause, Da as TypeofTypeAnnotation, Di as TSModuleDeclaration, Dn as JSXSpreadAttribute, Dr as QualifiedTypeIdentifier, Dt as ExportDefaultSpecifier, E as CallExpression, Ea as TypeScript, Ei as TSModuleBlock, En as JSXOpeningFragment, Er as Pureish, Et as ExportDefaultDeclaration, F as ClassPrivateMethod, Fa as VariableDeclarator, Fi as TSOptionalType, Fn as MemberExpression, Fr as SequenceExpression, Ft as Flow, G as DecimalLiteral, Gi as TSTupleType, Gn as Noop, Gr as SwitchCase, Gt as Function, H as ConditionalExpression, Ha as index_d_exports$1, Hi as TSStringKeyword, Hn as ModuleSpecifier, Hr as StringLiteralTypeAnnotation, Ht as ForOfStatement, I as ClassPrivateProperty, Ia as Variance, Ii as TSParameterProperty, In as MetaProperty, Ir as SpreadElement, It as FlowBaseAnnotation, J as DeclareExportAllDeclaration, Ji as TSTypeAnnotation, Jn as NullableTypeAnnotation, Jr as TSAnyKeyword, Jt as FunctionParent, K as Declaration, Ki as TSType, Kn as NullLiteral, Kr as SwitchStatement, Kt as FunctionDeclaration, L as ClassProperty, La as VoidTypeAnnotation, Li as TSParenthesizedType, Ln as Method, Lr as SpreadProperty$1, Lt as FlowDeclaration, M as ClassExpression, Ma as UserWhitespacable, Mi as TSNullKeyword, Mn as Literal, Mr as RestProperty$1, Mt as ExpressionStatement, N as ClassImplements, Na as V8IntrinsicIdentifier, Ni as TSNumberKeyword, Nn as LogicalExpression, Nr as ReturnStatement, Nt as ExpressionWrapper, O as Class, Oa as UnaryExpression, Oi as TSNamedTupleMember, On as JSXSpreadChild, Or as RecordExpression, Ot as ExportNamedDeclaration, P as ClassMethod, Pa as VariableDeclaration, Pi as TSObjectKeyword, Pn as Loop, Pr as Scopable, Pt as File, Q as DeclareModule, Qi as TSTypeOperator, Qn as NumericLiteral, Qr as TSBigIntKeyword, Qt as Identifier, R as Comment, Ra as While, Ri as TSPropertySignature, Rn as Miscellaneous, Rr as Standardized, Rt as FlowPredicate, S as BooleanLiteral, Sa as TypeCastExpression, Si as TSIntrinsicKeyword, Sn as JSXIdentifier, Sr as Private, St as EnumSymbolBody, T as BreakStatement, Ta as TypeParameterInstantiation, Ti as TSMethodSignature, Tn as JSXOpeningElement, Tr as Property, Tt as ExportDeclaration, U as ContinueStatement, Ui as TSSymbolKeyword, Un as NewExpression, Ur as StringTypeAnnotation, Ut as ForStatement, V as Conditional, Va as YieldExpression, Vi as TSSatisfiesExpression, Vn as ModuleExpression, Vr as StringLiteral, Vt as ForInStatement, W as DebuggerStatement, Wi as TSThisType, Wn as Node$1, Wr as Super, Wt as ForXStatement, X as DeclareFunction, Xi as TSTypeElement, Xn as NumberLiteralTypeAnnotation, Xr as TSAsExpression, Xt as FunctionTypeParam, Y as DeclareExportDeclaration, Yi as TSTypeAssertion, Yn as NumberLiteral$1, Yr as TSArrayType, Yt as FunctionTypeAnnotation, Z as DeclareInterface, Zi as TSTypeLiteral, Zn as NumberTypeAnnotation, Zr as TSBaseType, Zt as GenericTypeAnnotation, _ as BinaryExpression, _a as TryStatement, _i as TSInferType, _n as JSXClosingFragment, _r as PatternLike, _t as EnumMember, a as Aliases, aa as TSUndefinedKeyword, ai as TSDeclareMethod, an as ImportNamespaceSpecifier, ar as ObjectTypeCallProperty, at as DeprecatedAliases, b as BlockParent, ba as TypeAlias, bi as TSInterfaceDeclaration, bn as JSXExpressionContainer, br as PipelineTopicExpression, bt as EnumStringBody, c as ArrayExpression, ca as TSVoidKeyword, ci as TSEnumMember, cn as InferredPredicate, cr as ObjectTypeProperty, ct as DoExpression, d as ArrowFunctionExpression, da as TemplateLiteral, di as TSExternalModuleReference, dn as InterfaceTypeAnnotation, dr as OptionalCallExpression, dt as EmptyTypeAnnotation, ea as TSTypeParameterDeclaration, ei as TSCallSignatureDeclaration, en as Immutable, er as ObjectMember, et as DeclareOpaqueType, f as AssignmentExpression, fa as Terminatorless, fi as TSFunctionType, fn as InterpreterDirective, fr as OptionalIndexedAccessType, ft as EnumBody, g as Binary, ga as TopicReference, gi as TSIndexedAccessType, gn as JSXClosingElement, gr as Pattern, gt as EnumDefaultedMember, h as BigIntLiteral, ha as ThrowStatement, hi as TSIndexSignature, hn as JSXAttribute, hr as ParenthesizedExpression, ht as EnumDeclaration, i as Accessor, ia as TSTypeReference, ii as TSDeclareFunction, in as ImportDefaultSpecifier, ir as ObjectTypeAnnotation, it as Decorator, j as ClassDeclaration, ja as UpdateExpression, ji as TSNonNullExpression, jn as LabeledStatement, jr as RestElement, jt as Expression, k as ClassAccessorProperty, ka as UnaryLike, ki as TSNamespaceExportDeclaration, kn as JSXText, kr as RegExpLiteral, kt as ExportNamespaceSpecifier, l as ArrayPattern, la as TaggedTemplateExpression, li as TSExportAssignment, ln as InterfaceDeclaration, lr as ObjectTypeSpreadProperty, lt as DoWhileStatement, m as AwaitExpression, ma as ThisTypeAnnotation, mi as TSImportType, mn as JSX, mr as Options$1, mt as EnumBooleanMember, na as TSTypePredicate, ni as TSConstructSignatureDeclaration, nn as ImportAttribute, nr as ObjectPattern, nt as DeclareVariable, o as AnyTypeAnnotation, oa as TSUnionType, oi as TSEntityName, on as ImportSpecifier, or as ObjectTypeIndexer, ot as Directive, p as AssignmentPattern, pa as ThisExpression, pi as TSImportEqualsDeclaration, pn as IntersectionTypeAnnotation, pr as OptionalMemberExpression, pt as EnumBooleanBody, q as DeclareClass, qi as TSTypeAliasDeclaration, qn as NullLiteralTypeAnnotation, qr as SymbolTypeAnnotation, qt as FunctionExpression, r as generate$1, ra as TSTypeQuery, ri as TSConstructorType, rn as ImportDeclaration, rr as ObjectProperty, rt as DeclaredPredicate, s as ArgumentPlaceholder, sa as TSUnknownKeyword, si as TSEnumDeclaration, sn as IndexedAccessType, sr as ObjectTypeInternalSlot, st as DirectiveLiteral, t as GeneratorOptions, ta as TSTypeParameterInstantiation, ti as TSConditionalType, tn as Import, tr as ObjectMethod, tt as DeclareTypeAlias, u as ArrayTypeAnnotation, ua as TemplateElement, ui as TSExpressionWithTypeArguments, un as InterfaceExtends, ur as OpaqueType, ut as EmptyStatement, v as BindExpression, va as TupleExpression, vi as TSInstantiationExpression, vn as JSXElement, vr as PipelineBareFunction, vt as EnumNumberBody, w as BooleanTypeAnnotation, wa as TypeParameterDeclaration, wi as TSMappedType, wn as JSXNamespacedName, wr as Program, wt as ExportAllDeclaration, x as BlockStatement, xa as TypeAnnotation, xi as TSIntersectionType, xn as JSXFragment, xr as Placeholder, xt as EnumStringMember, y as Block, ya as TupleTypeAnnotation, yi as TSInterfaceBody, yn as JSXEmptyExpression, yr as PipelinePrimaryTopicReference, yt as EnumNumberMember, z as CommentTypeShorthand, za as WhileStatement, zi as TSQualifiedName, zn as MixedTypeAnnotation, zr as Statement, zt as FlowType } from "../chunk-wK3zEWUl.js"; import * as recast from "recast"; import { Options as RecastOptions } from "recast"; //#region node_modules/@babel/parser/typings/babel-parser.d.ts declare namespace babel_parser_d_exports { export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParseResult$1 as ParseResult, ParserOptions, PluginConfig as ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse$1 as parse, parseExpression, tokTypes }; } declare class Position { line: number; column: number; index: number; constructor(line: number, col: number, index: number); } type SyntaxPlugin = "flow" | "typescript" | "jsx" | "pipelineOperator" | "placeholders"; type ParseErrorCode = "BABEL_PARSER_SYNTAX_ERROR" | "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED"; interface ParseErrorSpecification<ErrorDetails> { code: ParseErrorCode; reasonCode: string; syntaxPlugin?: SyntaxPlugin; missingPlugin?: string | string[]; loc: Position; details: ErrorDetails; pos: number; } type ParseError$1<ErrorDetails> = SyntaxError & ParseErrorSpecification<ErrorDetails>; type BABEL_8_BREAKING = false; type IF_BABEL_7<V> = false extends BABEL_8_BREAKING ? V : never; type Plugin$1 = "asyncDoExpressions" | IF_BABEL_7<"asyncGenerators"> | IF_BABEL_7<"bigInt"> | IF_BABEL_7<"classPrivateMethods"> | IF_BABEL_7<"classPrivateProperties"> | IF_BABEL_7<"classProperties"> | IF_BABEL_7<"classStaticBlock"> | IF_BABEL_7<"decimal"> | "decorators-legacy" | "deferredImportEvaluation" | "decoratorAutoAccessors" | "destructuringPrivate" | IF_BABEL_7<"deprecatedImportAssert"> | "doExpressions" | IF_BABEL_7<"dynamicImport"> | IF_BABEL_7<"explicitResourceManagement"> | "exportDefaultFrom" | IF_BABEL_7<"exportNamespaceFrom"> | "flow" | "flowComments" | "functionBind" | "functionSent" | "importMeta" | "jsx" | IF_BABEL_7<"jsonStrings"> | IF_BABEL_7<"logicalAssignment"> | IF_BABEL_7<"importAssertions"> | IF_BABEL_7<"importReflection"> | "moduleBlocks" | IF_BABEL_7<"moduleStringNames"> | IF_BABEL_7<"nullishCoalescingOperator"> | IF_BABEL_7<"numericSeparator"> | IF_BABEL_7<"objectRestSpread"> | IF_BABEL_7<"optionalCatchBinding"> | IF_BABEL_7<"optionalChaining"> | "partialApplication" | "placeholders" | IF_BABEL_7<"privateIn"> | IF_BABEL_7<"regexpUnicodeSets"> | "sourcePhaseImports" | "throwExpressions" | IF_BABEL_7<"topLevelAwait"> | "v8intrinsic" | ParserPluginWithOptions[0]; type ParserPluginWithOptions = ["decorators", DecoratorsPluginOptions] | ["discardBinding", { syntaxType: "void"; }] | ["estree", { classFeatures?: boolean; }] | IF_BABEL_7<["importAttributes", { deprecatedAssertSyntax: boolean; }]> | IF_BABEL_7<["moduleAttributes", { version: "may-2020"; }]> | ["optionalChainingAssign", { version: "2023-07"; }] | ["pipelineOperator", PipelineOperatorPluginOptions] | ["recordAndTuple", RecordAndTuplePluginOptions] | ["flow", FlowPluginOptions] | ["typescript", TypeScriptPluginOptions]; type PluginConfig = Plugin$1 | ParserPluginWithOptions; interface DecoratorsPluginOptions { decoratorsBeforeExport?: boolean; allowCallParenthesized?: boolean; } interface PipelineOperatorPluginOptions { proposal: BABEL_8_BREAKING extends false ? "minimal" | "fsharp" | "hack" | "smart" : "fsharp" | "hack"; topicToken?: "%" | "#" | "@@" | "^^" | "^"; } interface RecordAndTuplePluginOptions { syntaxType: "bar" | "hash"; } type FlowPluginOptions = BABEL_8_BREAKING extends true ? { all?: boolean; enums?: boolean; } : { all?: boolean; }; interface TypeScriptPluginOptions { dts?: boolean; disallowAmbiguousJSXLike?: boolean; } type Plugin = PluginConfig; type SourceType = "script" | "commonjs" | "module" | "unambiguous"; interface Options { /** * By default, import and export declarations can only appear at a program's top level. * Setting this option to true allows them anywhere where a statement is allowed. */ allowImportExportEverywhere?: boolean; /** * By default, await use is not allowed outside of an async function. * Set this to true to accept such code. */ allowAwaitOutsideFunction?: boolean; /** * By default, a return statement at the top level raises an error. * Set this to true to accept such code. */ allowReturnOutsideFunction?: boolean; /** * By default, new.target use is not allowed outside of a function or class. * Set this to true to accept such code. */ allowNewTargetOutsideFunction?: boolean; /** * By default, super calls are not allowed outside of a method. * Set this to true to accept such code. */ allowSuperOutsideMethod?: boolean; /** * By default, exported identifiers must refer to a declared variable. * Set this to true to allow export statements to reference undeclared variables. */ allowUndeclaredExports?: boolean; /** * By default, yield use is not allowed outside of a generator function. * Set this to true to accept such code. */ allowYieldOutsideFunction?: boolean; /** * By default, Babel parser JavaScript code according to Annex B syntax. * Set this to `false` to disable such behavior. */ annexB?: boolean; /** * By default, Babel attaches comments to adjacent AST nodes. * When this option is set to false, comments are not attached. * It can provide up to 30% performance improvement when the input code has many comments. * @babel/eslint-parser will set it for you. * It is not recommended to use attachComment: false with Babel transform, * as doing so removes all the comments in output code, and renders annotations such as * /* istanbul ignore next *\/ nonfunctional. */ attachComment?: boolean; /** * By default, Babel always throws an error when it finds some invalid code. * When this option is set to true, it will store the parsing error and * try to continue parsing the invalid input file. */ errorRecovery?: boolean; /** * Indicate the mode the code should be parsed in. * Can be one of "script", "commonjs", "module", or "unambiguous". Defaults to "script". * "unambiguous" will make @babel/parser attempt to guess, based on the presence * of ES6 import or export statements. * Files with ES6 imports and exports are considered "module" and are otherwise "script". * * Use "commonjs" to parse code that is intended to be run in a CommonJS environment such as Node.js. */ sourceType?: SourceType; /** * Correlate output AST nodes with their source filename. * Useful when generating code and source maps from the ASTs of multiple input files. */ sourceFilename?: string; /** * By default, all source indexes start from 0. * You can provide a start index to alternatively start with. * Useful for integration with other source tools. */ startIndex?: number; /** * By default, the first line of code parsed is treated as line 1. * You can provide a line number to alternatively start with. * Useful for integration with other source tools. */ startLine?: number; /** * By default, the parsed code is treated as if it starts from line 1, column 0. * You can provide a column number to alternatively start with. * Useful for integration with other source tools. */ startColumn?: number; /** * Array containing the plugins that you want to enable. */ plugins?: Plugin[]; /** * Should the parser work in strict mode. * Defaults to true if sourceType === 'module'. Otherwise, false. */ strictMode?: boolean; /** * Adds a ranges property to each node: [node.start, node.end] */ ranges?: boolean; /** * Adds all parsed tokens to a tokens property on the File node. */ tokens?: boolean; /** * By default, the parser adds information about parentheses by setting * `extra.parenthesized` to `true` as needed. * When this option is `true` the parser creates `ParenthesizedExpression` * AST nodes instead of using the `extra` property. */ createParenthesizedExpressions?: boolean; /** * The default is false in Babel 7 and true in Babel 8 * Set this to true to parse it as an `ImportExpression` node. * Otherwise `import(foo)` is parsed as `CallExpression(Import, [Identifier(foo)])`. */ createImportExpressions?: boolean; } type ParserOptions = Partial<Options>; type ParseError = ParseError$1<object>; type ParseResult$1<Result extends File | Expression = File> = Result & { comments: File["comments"]; errors: null | ParseError[]; tokens?: File["tokens"]; }; /** * Parse the provided code as an entire ECMAScript program. */ declare function parse$1(input: string, options?: ParserOptions): ParseResult$1<File>; declare function parseExpression(input: string, options?: ParserOptions): ParseResult$1<Expression>; declare const tokTypes: { // todo(flow->ts) real token type [name: string]: any; }; //#endregion //#region node_modules/@types/babel__template/index.d.ts interface TemplateBuilderOptions extends ParserOptions { /** * A set of placeholder names to automatically accept. * Items in this list do not need to match `placeholderPattern`. * * This option cannot be used when using `%%foo%%` style placeholders. */ placeholderWhitelist?: Set<string> | null | undefined; /** * A pattern to search for when looking for `Identifier` and `StringLiteral` * nodes that should be considered as placeholders. * * `false` will disable placeholder searching placeholders, leaving only * the `placeholderWhitelist` value to find replacements. * * This option cannot be used when using `%%foo%%` style placeholders. * * @default /^[_$A-Z0-9]+$/ */ placeholderPattern?: RegExp | false | null | undefined; /** * Set this to `true` to preserve comments from the template string * into the resulting AST, or `false` to automatically discard comments. * * @default false */ preserveComments?: boolean | null | undefined; /** * Set to `true` to use `%%foo%%` style placeholders, `false` to use legacy placeholders * described by `placeholderPattern` or `placeholderWhitelist`. * * When it is not set, it behaves as `true` if there are syntactic placeholders, otherwise as `false`. * * @since 7.4.0 */ syntacticPlaceholders?: boolean | null | undefined; } interface TemplateBuilder<T> { /** * Build a new builder, merging the given options with the previous ones. */ (opts: TemplateBuilderOptions): TemplateBuilder<T>; /** * Building from a string produces an AST builder function by default. */ (code: string, opts?: TemplateBuilderOptions): (arg?: PublicReplacements) => T; /** * Building from a template literal produces an AST builder function by default. */ (tpl: TemplateStringsArray, ...args: unknown[]): (arg?: PublicReplacements) => T; /** * Allow users to explicitly create templates that produce ASTs, * skipping the need for an intermediate function. * * Does not allow `%%foo%%` style placeholders. */ ast: { (tpl: string, opts?: TemplateBuilderOptions): T; (tpl: TemplateStringsArray, ...args: unknown[]): T; }; } type PublicReplacements = { [index: string]: unknown; } | unknown[]; declare const smart: TemplateBuilder<Statement | Statement[]>; declare const statement: TemplateBuilder<Statement>; declare const statements: TemplateBuilder<Statement[]>; declare const expression: TemplateBuilder<Expression>; declare const program: TemplateBuilder<Program>; type DefaultTemplateBuilder = typeof smart & { smart: typeof smart; statement: typeof statement; statements: typeof statements; expression: typeof expression; program: typeof program; ast: typeof smart.ast; }; declare const templateBuilder: DefaultTemplateBuilder; //#endregion //#region node_modules/@types/babel__traverse/index.d.ts declare const traverse$1: { <S>(parent: Node$1, opts: TraverseOptions<S>, scope: Scope | undefined, state: S, parentPath?: NodePath): void; (parent: Node$1, opts?: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath): void; visitors: typeof visitors; verify: typeof visitors.verify; explode: typeof visitors.explode; cheap: (node: Node$1, enter: (node: Node$1) => void) => void; node: (node: Node$1, opts: TraverseOptions, scope?: Scope, state?: any, path?: NodePath, skipKeys?: Record<string, boolean>) => void; clearNode: (node: Node$1, opts?: Options$1) => void; removeProperties: (tree: Node$1, opts?: Options$1) => Node$1; hasType: (tree: Node$1, type: Node$1["type"], denylistTypes?: string[]) => boolean; cache: typeof cache; }; declare namespace visitors { /** * `explode()` will take a `Visitor` object with all of the various shorthands * that we support, and validates & normalizes it into a common format, ready * to be used in traversal. * * The various shorthands are: * - `Identifier() { ... }` -> `Identifier: { enter() { ... } }` * - `"Identifier|NumericLiteral": { ... }` -> `Identifier: { ... }, NumericLiteral: { ... }` * - Aliases in `@babel/types`: e.g. `Property: { ... }` -> `ObjectProperty: { ... }, ClassProperty: { ... }` * * Other normalizations are: * - Visitors of virtual types are wrapped, so that they are only visited when their dynamic check passes * - `enter` and `exit` functions are wrapped in arrays, to ease merging of visitors */ function explode<S = unknown>(visitor: Visitor<S>): { [Type in Exclude<Node$1, DeprecatedAliases>["type"]]?: VisitNodeObject<S, Extract<Node$1, { type: Type; }>> }; function verify(visitor: Visitor): void; function merge<State>(visitors: Array<Visitor<State>>): Visitor<State>; function merge(visitors: Visitor[], states?: any[], wrapper?: (stateKey: any, visitorKey: keyof Visitor, func: VisitNodeFunction<unknown, Node$1>) => VisitNodeFunction<unknown, Node$1> | null): Visitor; } declare namespace cache { let path: WeakMap<Node$1, Map<Node$1, NodePath>>; let scope: WeakMap<Node$1, Scope>; function clear(): void; function clearPath(): void; function clearScope(): void; } type TraverseOptions<S = Node$1> = { scope?: Scope; noScope?: boolean; denylist?: NodeType[]; /** @deprecated will be removed in Babel 8 */ blacklist?: NodeType[]; shouldSkip?: (node: NodePath) => boolean; } & Visitor<S>; declare class Scope { /** * This searches the current "scope" and collects all references/bindings * within. */ constructor(path: NodePath, parentScope?: Scope); uid: number; path: NodePath; block: Node$1; labels: Map<string, NodePath<LabeledStatement>>; parentBlock: Node$1; parent: Scope; hub: HubInterface; bindings: { [name: string]: Binding; }; references: { [name: string]: true; }; globals: { [name: string]: Identifier | JSXIdentifier; }; uids: { [name: string]: boolean; }; data: Record<string | symbol, unknown>; crawling: boolean; static globals: string[]; /** Variables available in current context. */ static contextVariables: string[]; /** Traverse node with current scope and path. */ traverse<S>(node: Node$1 | Node$1[], opts: TraverseOptions<S>, state: S): void; traverse(node: Node$1 | Node$1[], opts?: TraverseOptions, state?: any): void; /** Generate a unique identifier and add it to the current scope. */ generateDeclaredUidIdentifier(name?: string): Identifier; /** Generate a unique identifier. */ generateUidIdentifier(name?: string): Identifier; /** Generate a unique `_id1` binding. */ generateUid(name?: string): string; /** Generate a unique identifier based on a node. */ generateUidIdentifierBasedOnNode(parent: Node$1, defaultName?: string): Identifier; /** * Determine whether evaluating the specific input `node` is a consequenceless reference. ie. * evaluating it wont result in potentially arbitrary code from being ran. The following are * whitelisted and determined not to cause side effects: * * - `this` expressions * - `super` expressions * - Bound identifiers */ isStatic(node: Node$1): boolean; /** Possibly generate a memoised identifier if it is not static and has consequences. */ maybeGenerateMemoised(node: Node$1, dontPush?: boolean): Identifier; checkBlockScopedCollisions(local: Binding, kind: BindingKind, name: string, id: object): void; rename(oldName: string, newName?: string, block?: Node$1): void; dump(): void; toArray(node: Node$1, i?: number | boolean, arrayLikeIsIterable?: boolean): ArrayExpression | CallExpression | Identifier; hasLabel(name: string): boolean; getLabel(name: string): NodePath<LabeledStatement> | undefined; registerLabel(path: NodePath<LabeledStatement>): void; registerDeclaration(path: NodePath): void; buildUndefinedNode(): UnaryExpression; registerConstantViolation(path: NodePath): void; registerBinding(kind: BindingKind, path: NodePath, bindingPath?: NodePath): void; addGlobal(node: Identifier | JSXIdentifier): void; hasUid(name: string): boolean; hasGlobal(name: string): boolean; hasReference(name: string): boolean; isPure(node: Node$1, constantsOnly?: boolean): boolean; /** * Set some arbitrary data on the current scope. */ setData(key: string, val: any): any; /** * Recursively walk up scope tree looking for the data `key`. */ getData(key: string): any; /** * Recursively walk up scope tree looking for the data `key` and if it exists, * remove it. */ removeData(key: string): void; crawl(): void; push(opts: { id: LVal; init?: Expression; unique?: boolean; _blockHoist?: number | undefined; kind?: "var" | "let" | "const"; }): void; /** Walk up to the top of the scope tree and get the `Program`. */ getProgramParent(): Scope; /** Walk up the scope tree until we hit either a Function or return null. */ getFunctionParent(): Scope | null; /** * Walk up the scope tree until we hit either a BlockStatement/Loop/Program/Function/Switch or reach the * very top and hit Program. */ getBlockParent(): Scope; /** * Walk up from a pattern scope (function param initializer) until we hit a non-pattern scope, * then returns its block parent * @returns An ancestry scope whose path is a block parent */ getPatternParent(): Scope; /** Walks the scope tree and gathers **all** bindings. */ getAllBindings(): Record<string, Binding>; /** Walks the scope tree and gathers all declarations of `kind`. */ getAllBindingsOfKind(...kinds: string[]): Record<string, Binding>; bindingIdentifierEquals(name: string, node: Node$1): boolean; getBinding(name: string): Binding | undefined; getOwnBinding(name: string): Binding | undefined; getBindingIdentifier(name: string): Identifier; getOwnBindingIdentifier(name: string): Identifier; hasOwnBinding(name: string): boolean; hasBinding(name: string, optsOrNoGlobals?: boolean | { noGlobals?: boolean; noUids?: boolean; }): boolean; parentHasBinding(name: string, opts?: { noGlobals?: boolean; noUids?: boolean; }): boolean; /** Move a binding of `name` to another `scope`. */ moveBindingTo(name: string, scope: Scope): void; removeOwnBinding(name: string): void; removeBinding(name: string): void; } type BindingKind = "var" | "let" | "const" | "module" | "hoisted" | "param" | "local" | "unknown"; /** * This class is responsible for a binding inside of a scope. * * It tracks the following: * * * Node path. * * Amount of times referenced by other nodes. * * Paths to nodes that reassign or modify this binding. * * The kind of binding. (Is it a parameter, declaration etc) */ declare class Binding { constructor(opts: { identifier: Identifier; scope: Scope; path: NodePath; kind: BindingKind; }); identifier: Identifier; scope: Scope; path: NodePath; kind: BindingKind; referenced: boolean; references: number; referencePaths: NodePath[]; constant: boolean; constantViolations: NodePath[]; hasDeoptedValue: boolean; hasValue: boolean; value: any; deopValue(): void; setValue(value: any): void; clearValue(): void; /** Register a constant violation with the provided `path`. */ reassign(path: NodePath): void; /** Increment the amount of references to this binding. */ reference(path: NodePath): void; /** Decrement the amount of references to this binding. */ dereference(): void; } type Visitor<S = unknown> = VisitNodeObject<S, Node$1> & { [N in Node$1 as N["type"]]?: VisitNode<S, N extends { type: N["type"]; } ? N : never> } & { [K in keyof Aliases]?: VisitNode<S, Aliases[K]> } & { [K in keyof VirtualTypeAliases]?: VisitNode<S, VirtualTypeAliases[K]> } & { // Babel supports `NodeTypesWithoutComment | NodeTypesWithoutComment | ... ` but it is // too complex for TS. So we type it as a general visitor only if the key contains `|` // this is good enough for non-visitor traverse options e.g. `noScope` [k: `${string}|${string}`]: VisitNode<S, Node$1>; }; type VisitNode<S, P extends Node$1> = VisitNodeFunction<S, P> | VisitNodeObject<S, P>; type VisitNodeFunction<S, P extends Node$1> = (this: S, path: NodePath<P>, state: S) => void; type NodeType = Node$1["type"] | keyof Aliases; interface VisitNodeObject<S, P extends Node$1> { enter?: VisitNodeFunction<S, P>; exit?: VisitNodeFunction<S, P>; } type NodeKeyOfArrays<T extends Node$1> = { [P in keyof T]-?: T[P] extends Array<Node$1 | null | undefined> ? P : never }[keyof T]; type NodePaths<T extends Node$1 | readonly Node$1[]> = T extends readonly Node$1[] ? { -readonly [K in keyof T]: NodePath<Extract<T[K], Node$1>> } : T extends Node$1 ? [NodePath<T>] : never; type NodeListType<N, K extends keyof N> = N[K] extends Array<infer P> ? (P extends Node$1 ? P : never) : never; type NodesInsertionParam<T extends Node$1> = T | readonly T[] | [T, ...T[]]; declare class NodePath<T = Node$1> { constructor(hub: HubInterface, parent: Node$1); parent: Node$1; hub: Hub; data: Record<string | symbol, unknown>; context: TraversalContext; scope: Scope; contexts: TraversalContext[]; state: any; opts: any; // exploded TraverseOptions skipKeys: Record<string, boolean> | null; parentPath: T extends Program ? null : NodePath; container: Node$1 | Node$1[] | null; listKey: string | null; key: string | number | null; node: T; type: T extends Node$1 ? T["type"] : T extends null | undefined ? undefined : Node$1["type"] | undefined; shouldSkip: boolean; shouldStop: boolean; removed: boolean; inList: boolean; parentKey: string; typeAnnotation: object; static get<C extends Node$1, K extends keyof C>(opts: { hub?: HubInterface; parentPath: NodePath | null; parent: Node$1; container: C; key: K; }): NodePath<C[K]>; static get<C extends Node$1, L extends NodeKeyOfArrays<C>>(opts: { hub?: HubInterface; parentPath: NodePath | null; parent: Node$1; container: C; listKey: L; key: number; }): C[L] extends Array<Node$1 | null | undefined> ? NodePath<C[L][number]> : never; getScope(scope: Scope): Scope; setData(key: string | symbol, val: any): any; getData(key: string | symbol, def?: any): any; hasNode(): this is NodePath<Exclude<T, null | undefined>>; buildCodeFrameError(msg: string, Error?: ErrorConstructor): Error; traverse<T>(visitor: TraverseOptions<T>, state: T): void; traverse(visitor: TraverseOptions): void; set(key: string, node: any): void; getPathLocation(): string; // Example: https://github.com/babel/babel/blob/63204ae51e020d84a5b246312f5eeb4d981ab952/packages/babel-traverse/src/path/modification.js#L83 debug(buildMessage: () => string): void; // #region ------------------------- ancestry ------------------------- /** * Starting at the parent path of the current `NodePath` and going up the * tree, return the first `NodePath` that causes the provided `callback` * to return a truthy value, or `null` if the `callback` never returns a * truthy value. */ findParent(callback: (path: NodePath) => boolean): NodePath | null; /** * Starting at current `NodePath` and going up the tree, return the first * `NodePath` that causes the provided `callback` to return a truthy value, * or `null` if the `callback` never returns a truthy value. */ find(callback: (path: NodePath) => boolean): NodePath | null; /** Get the parent function of the current path. */ getFunctionParent(): NodePath<Function> | null; /** Walk up the tree until we hit a parent node path in a list. */ getStatementParent(): NodePath<Statement> | null; /** * Get the deepest common ancestor and then from it, get the earliest relationship path * to that ancestor. * * Earliest is defined as being "before" all the other nodes in terms of list container * position and visiting key. */ getEarliestCommonAncestorFrom(paths: NodePath[]): NodePath; /** Get the earliest path in the tree where the provided `paths` intersect. */ getDeepestCommonAncestorFrom(paths: NodePath[], filter?: (deepest: Node$1, i: number, ancestries: NodePath[][]) => NodePath): NodePath; /** * Build an array of node paths containing the entire ancestry of the current node path. * * NOTE: The current node path is included in this. */ getAncestry(): [this, ...NodePath[]]; /** * A helper to find if `this` path is an ancestor of `maybeDescendant` */ isAncestor(maybeDescendant: NodePath): boolean; /** * A helper to find if `this` path is a descendant of `maybeAncestor` */ isDescendant(maybeAncestor: NodePath): boolean; inType(...candidateTypes: string[]): boolean; // #endregion // #region ------------------------- inference ------------------------- /** Infer the type of the current `NodePath`. */ getTypeAnnotation(): FlowType | TSType; isBaseType(baseName: string, soft?: boolean): boolean; couldBeBaseType(name: string): boolean; baseTypeStrictlyMatches(rightArg: NodePath): boolean; isGenericType(genericName: string): boolean; // #endregion // #region ------------------------- replacement ------------------------- /** * Replace a node with an array of multiple. This method performs the following steps: * * - Inherit the comments of first provided node with that of the current node. * - Insert the provided nodes after the current node. * - Remove the current node. */ replaceWithMultiple<Nodes extends Node$1 | readonly Node$1[] | [Node$1, ...Node$1[]]>(nodes: Nodes): NodePaths<Nodes>; /** * Parse a string as an expression and replace the current node with the result. * * NOTE: This is typically not a good idea to use. Building source strings when * transforming ASTs is an antipattern and SHOULD NOT be encouraged. Even if it's * easier to use, your transforms will be extremely brittle. */ replaceWithSourceString(replacement: string): [NodePath]; /** Replace the current node with another. */ replaceWith<R extends Node$1>(replacementPath: R | NodePath<R>): [NodePath<R>]; replaceWith<R extends NodePath>(replacementPath: R): [R]; /** * This method takes an array of statements nodes and then explodes it * into expressions. This method retains completion records which is * extremely important to retain original semantics. */ replaceExpressionWithStatements(nodes: Statement[]): NodePaths<Expression | Statement>; replaceInline<Nodes extends Node$1 | readonly Node$1[] | [Node$1, ...Node$1[]]>(nodes: Nodes): NodePaths<Nodes>; // #endregion // #region ------------------------- evaluation ------------------------- /** * Walk the input `node` and statically evaluate if it's truthy. * * Returning `true` when we're sure that the expression will evaluate to a * truthy value, `false` if we're sure that it will evaluate to a falsy * value and `undefined` if we aren't sure. Because of this please do not * rely on coercion when using this method and check with === if it's false. */ evaluateTruthy(): boolean | undefined; /** * Walk the input `node` and statically evaluate it. * * Returns an object in the form `{ confident, value, deopt }`. `confident` * indicates whether or not we had to drop out of evaluating the expression * because of hitting an unknown node that we couldn't confidently find the * value of, in which case `deopt` is the path of said node. * * Example: * * t.evaluate(parse("5 + 5")) // { confident: true, value: 10 } * t.evaluate(parse("!true")) // { confident: true, value: false } * t.evaluate(parse("foo + foo")) // { confident: false, value: undefined, deopt: NodePath } */ evaluate(): { confident: boolean; value: any; deopt?: NodePath; }; // #endregion // #region ------------------------- introspection ------------------------- /** * Match the current node if it matches the provided `pattern`. * * For example, given the match `React.createClass` it would match the * parsed nodes of `React.createClass` and `React["createClass"]`. */ matchesPattern(pattern: string, allowPartial?: boolean): boolean; /** * Check whether we have the input `key`. If the `key` references an array then we check * if the array has any items, otherwise we just check if it's falsy. */ has(key: string): boolean; // has(key: keyof T): boolean; isStatic(): boolean; /** Alias of `has`. */ is(key: string): boolean; // is(key: keyof T): boolean; /** Opposite of `has`. */ isnt(key: string): boolean; // isnt(key: keyof T): boolean; /** Check whether the path node `key` strict equals `value`. */ equals(key: string, value: any): boolean; // equals(key: keyof T, value: any): boolean; /** * Check the type against our stored internal type of the node. This is handy when a node has * been removed yet we still internally know the type and need it to calculate node replacement. */ isNodeType(type: string): boolean; /** * This checks whether or not we're in one of the following positions: * * for (KEY in right); * for (KEY;;); * * This is because these spots allow VariableDeclarations AND normal expressions so we need * to tell the path replacement that it's ok to replace this with an expression. */ canHaveVariableDeclarationOrExpression(): boolean; /** * This checks whether we are swapping an arrow function's body between an * expression and a block statement (or vice versa). * * This is because arrow functions may implicitly return an expression, which * is the same as containing a block statement. */ canSwapBetweenExpressionAndStatement(replacement: Node$1): boolean; /** Check whether the current path references a completion record */ isCompletionRecord(allowInsideFunction?: boolean): boolean; /** * Check whether or not the current `key` allows either a single statement or block statement * so we can explode it if necessary. */ isStatementOrBlock(): boolean; /** Check if the currently assigned path references the `importName` of `moduleSource`. */ referencesImport(moduleSource: string, importName: string): boolean; /** Get the source code associated with this node. */ getSource(): string; /** Check if the current path will maybe execute before another path */ willIMaybeExecuteBefore(target: NodePath): boolean; resolve(dangerous?: boolean, resolved?: NodePath[]): NodePath; isConstantExpression(): boolean; isInStrictMode(): boolean; // #endregion // #region ------------------------- context ------------------------- call(key: string): boolean; isDenylisted(): boolean; /** @deprecated will be removed in Babel 8 */ isBlacklisted(): boolean; visit(): boolean; skip(): void; skipKey(key: string): void; stop(): void; setScope(): void; setContext(context?: TraversalContext): this; /** * Here we resync the node paths `key` and `container`. If they've changed according * to what we have stored internally then we attempt to resync by crawling and looking * for the new values. */ resync(): void; popContext(): void; pushContext(context: TraversalContext): void; requeue(pathToQueue?: NodePath): void; // #endregion // #region ------------------------- removal ------------------------- remove(): void; // #endregion // #region ------------------------- conversion ------------------------- toComputedKey(): PrivateName | Expression; /** @deprecated Use `arrowFunctionToExpression` */ arrowFunctionToShadowed(): void; /** * Given an arbitrary function, process its content as if it were an arrow function, moving references * to "this", "arguments", "super", and such into the function's parent scope. This method is useful if * you have wrapped some set of items in an IIFE or other function, but want "this", "arguments", and super" * to continue behaving as expected. */ unwrapFunctionEnvironment(): void; /** * Convert a given arrow function into a normal ES5 function expression. */ arrowFunctionToExpression({ allowInsertArrow, allowInsertArrowWithRest, /** @deprecated Use `noNewArrows` instead */specCompliant, noNewArrows }?: { allowInsertArrow?: boolean; allowInsertArrowWithRest?: boolean; specCompliant?: boolean; noNewArrows?: boolean; }): NodePath<Exclude<Function, Method | ArrowFunctionExpression> | CallExpression>; ensureBlock(this: NodePath<Loop | WithStatement | Function | LabeledStatement | CatchClause>): asserts this is NodePath<T & { body: BlockStatement; }>; // #endregion // #region ------------------------- modification ------------------------- /** Insert the provided nodes before the current one. */ insertBefore<Nodes extends NodesInsertionParam<Node$1>>(nodes: Nodes): NodePaths<Nodes>; /** * Insert the provided nodes after the current one. When inserting nodes after an * expression, ensure that the completion record is correct by pushing the current node. */ insertAfter<Nodes extends NodesInsertionParam<Node$1>>(nodes: Nodes): NodePaths<Nodes>; /** Update all sibling node paths after `fromIndex` by `incrementBy`. */ updateSiblingKeys(fromIndex: number, incrementBy: number): void; /** * Insert child nodes at the start of the current node. * @param listKey - The key at which the child nodes are stored (usually body). * @param nodes - the nodes to insert. */ unshiftContainer<T extends Node$1, K extends NodeKeyOfArrays<T>, Nodes extends NodesInsertionParam<NodeListType<T, K>>>(this: NodePath<T>, listKey: K, nodes: Nodes): NodePaths<Nodes>; /** * Insert child nodes at the end of the current node. * @param listKey - The key at which the child nodes are stored (usually body). * @param nodes - the nodes to insert. */ pushContainer<T extends Node$1, K extends NodeKeyOfArrays<T>, Nodes extends NodesInsertionParam<NodeListType<T, K>>>(this: NodePath<T>, listKey: K, nodes: Nodes): NodePaths<Nodes>; /** Hoist the current node to the highest scope possible and return a UID referencing it. */ hoist(scope: Scope): void; // #endregion // #region ------------------------- family ------------------------- getOpposite(): NodePath | null; getCompletionRecords(): NodePath[]; getSibling(key: string | number): NodePath; getPrevSibling(): NodePath; getNextSibling(): NodePath; getAllPrevSiblings(): NodePath[]; getAllNextSiblings(): NodePath[]; get<K extends keyof T>(key: K, context?: boolean | TraversalContext): NodePathResult<T[K]>; get(key: string, context?: boolean | TraversalContext): NodePath | NodePath[]; getBindingIdentifiers(duplicates: true): Record<string, Identifier[]>; getBindingIdentifiers(duplicates?: false): Record<string, Identifier>; getBindingIdentifiers(duplicates?: boolean): Record<string, Identifier | Identifier[]>; getOuterBindingIdentifiers(duplicates: true): Record<string, Identifier[]>; getOuterBindingIdentifiers(duplicates?: false): Record<string, Identifier>; getOuterBindingIdentifiers(duplicates?: boolean): Record<string, Identifier | Identifier[]>; getBindingIdentifierPaths(duplicates: true, outerOnly?: boolean): Record<string, Array<NodePath<Identifier>>>; getBindingIdentifierPaths(duplicates?: false, outerOnly?: boolean): Record<string, NodePath<Identifier>>; getBindingIdentifierPaths(duplicates?: boolean, outerOnly?: boolean): Record<string, NodePath<Identifier> | Array<NodePath<Identifier>>>; getOuterBindingIdentifierPaths(duplicates: true): Record<string, Array<NodePath<Identifier>>>; getOuterBindingIdentifierPaths(duplicates?: false): Record<string, NodePath<Identifier>>; getOuterBindingIdentifierPaths(duplicates?: boolean, outerOnly?: boolean): Record<string, NodePath<Identifier> | Array<NodePath<Identifier>>>; // #endregion // #region ------------------------- comments ------------------------- /** Share comments amongst siblings. */ shareCommentsWithSiblings(): void; addComment(type: CommentTypeShorthand, content: string, line?: boolean): void; /** Give node `comments` of the specified `type`. */ addComments(type: CommentTypeShorthand, comments: Comment[]): void; // #endregion // #region ------------------------- isXXX ------------------------- isAccessor(opts?: object): this is NodePath<Accessor>; isAnyTypeAnnotation(opts?: object): this is NodePath<AnyTypeAnnotation>; isArgumentPlaceholder(opts?: object): this is NodePath<ArgumentPlaceholder>; isArrayExpression(opts?: object): this is NodePath<ArrayExpression>; isArrayPattern(opts?: object): this is NodePath<ArrayPattern>; isArrayTypeAnnotation(opts?: object): this is NodePath<ArrayTypeAnnotation>; isArrowFunctionExpression(opts?: object): this is NodePath<ArrowFunctionExpression>; isAssignmentExpression(opts?: object): this is NodePath<AssignmentExpression>; isAssignmentPattern(opts?: object): this is NodePath<AssignmentPattern>; isAwaitExpression(opts?: object): this is NodePath<AwaitExpression>; isBigIntLiteral(opts?: object): this is NodePath<BigIntLiteral>; isBinary(opts?: object): this is NodePath<Binary>; isBinaryExpression(opts?: object): this is NodePath<BinaryExpression>; isBindExpression(opts?: object): this is NodePath<BindExpression>; isBlock(opts?: object): this is NodePath<Block>; isBlockParent(opts?: object): this is NodePath<BlockParent>; isBlockStatement(opts?: object): this is NodePath<BlockStatement>; isBooleanLiteral(opts?: object): this is NodePath<BooleanLiteral>; isBooleanLiteralTypeAnnotation(opts?: object): this is NodePath<BooleanLiteralTypeAnnotation>; isBooleanTypeAnnotation(opts?: object): this is NodePath<BooleanTypeAnnotation>; isBreakStatement(opts?: object): this is NodePath<BreakStatement>; isCallExpression(opts?: object): this is NodePath<CallExpression>; isCatchClause(opts?: object): this is NodePath<CatchClause>; isClass(opts?: object): this is NodePath<Class>; isClassAccessorProperty(opts?: object): this is NodePath<ClassAccessorProperty>; isClassBody(opts?: object): this is NodePath<ClassBody>; isClassDeclaration(opts?: object): this is NodePath<ClassDeclaration>; isClassExpression(opts?: object): this is NodePath<ClassExpression>; isClassImplements(opts?: object): this is NodePath<ClassImplements>; isClassMethod(opts?: object): this is NodePath<ClassMethod>; isClassPrivateMethod(opts?: object): this is NodePath<ClassPrivateMethod>; isClassPrivateProperty(opts?: object): this is NodePath<ClassPrivateProperty>; isClassProperty(opts?: object): this is NodePath<ClassProperty>; isCompletionStatement(opts?: object): this is NodePath<CompletionStatement>; isConditional(opts?: object): this is NodePath<Conditional>; isConditionalExpression(opts?: object): this is NodePath<ConditionalExpression>; isContinueStatement(opts?: object): this is NodePath<ContinueStatement>; isDebuggerStatement(opts?: object): this is NodePath<DebuggerStatement>; isDecimalLiteral(opts?: object): this is NodePath<DecimalLiteral>; isDeclaration(opts?: object): this is NodePath<Declaration>; isDeclareClass(opts?: object): this is NodePath<DeclareClass>; isDeclareExportAllDeclaration(opts?: object): this is NodePath<DeclareExportAllDeclaration>; isDeclareExportDeclaration(opts?: object): this is NodePath<DeclareExportDeclaration>; isDeclareFunction(opts?: object): this is NodePath<DeclareFunction>; isDeclareInterface(opts?: object): this is NodePath<DeclareInterface>; isDeclareModule(opts?: object): this is NodePath<DeclareModule>; isDeclareModuleExports(opts?: object): this is NodePath<DeclareModuleExports>; isDeclareOpaqueType(opts?: object): this is NodePath<DeclareOpaqueType>; isDeclareTypeAlias(opts?: object): this is NodePath<DeclareTypeAlias>; isDeclareVariable(opts?: object): this is NodePath<DeclareVariable>; isDeclaredPredicate(opts?: object): this is NodePath<DeclaredPredicate>; isDecorator(opts?: object): this is NodePath<Decorator>; isDirective(opts?: object): this is NodePath<Directive>; isDirectiveLiteral(opts?: object): this is NodePath<DirectiveLiteral>; isDoExpression(opts?: object): this is NodePath<DoExpression>; isDoWhileStatement(opts?: object): this is NodePath<DoWhileStatement>; isEmptyStatement(opts?: object): this is NodePath<EmptyStatement>; isEmptyTypeAnnotation(opts?: object): this is NodePath<EmptyTypeAnnotation>; isEnumBody(opts?: object): this is NodePath<EnumBody>; isEnumBooleanBody(opts?: object): this is NodePath<EnumBooleanBody>; isEnumBooleanMember(opts?: object): this is NodePath<EnumBooleanMember>; isEnumDeclaration(opts?: object): this is NodePath<EnumDeclaration>; isEnumDefaultedMember(opts?: object): this is NodePath<EnumDefaultedMember>; isEnumMember(opts?: object): this is NodePath<EnumMember>; isEnumNumberBody(opts?: object): this is NodePath<EnumNumberBody>; isEnumNumberMember(opts?: object): this is NodePath<EnumNumberMember>; isEnumStringBody(opts?: object): this is NodePath<EnumStringBody>; isEnumStringMember(opts?: object): this is NodePath<EnumStringMember>; isEnumSymbolBody(opts?: object): this is NodePath<EnumSymbolBody>; isExistsTypeAnnotation(opts?: object): this is NodePath<ExistsTypeAnnotation>; isExportAllDeclaration(opts?: object): this is NodePath<ExportAllDeclaration>; isExportDeclaration(opts?: object): this is NodePath<ExportDeclaration>; isExportDefaultDeclaration(opts?: object): this is NodePath<ExportDefaultDeclaration>; isExportDefaultSpecifier(opts?: object): this is NodePath<ExportDefaultSpecifier>; isExportNamedDeclaration(opts?: object): this is NodePath<ExportNamedDeclaration>; isExportNamespaceSpecifier(op