UNPKG

@hey-api/openapi-ts

Version:

🌀 OpenAPI to TypeScript codegen. Production-grade SDKs, Zod schemas, TanStack Query hooks, and 20+ plugins. Used by Vercel, OpenCode, and PayPal.

1,318 lines (1,317 loc) • 412 kB
import { n as UserConfig } from "./types-KzipN7UT.mjs"; import { AnalysisContext, BindingKind, ExportModule, File, FromRef, ImportModule, Language, Logger, Logger as Logger$1, Node, NodeName, NodeNameSanitizer, NodeRelationship, NodeScope, Ref, RenderContext, Renderer, Symbol } from "@hey-api/codegen-core"; import { BaseOutput, Casing, Context, DefinePlugin, DefinePlugin as DefinePlugin$1, FeatureToggle, IR, IR as IR$1, NameTransformer, NamingConfig, NamingOptions, NamingRule, OpenApi, OpenApiMetaObject, OpenApiOperationObject, OpenApiParameterObject, OpenApiRequestBodyObject, OpenApiResponseObject, OpenApiSchemaObject, OperationPath, OperationPathStrategy, OperationStrategy, OperationsStrategy, Plugin, Plugin as Plugin$1, RequestSchemaContext, ResolvedRequestValidatorLayer, SchemaVisitorContext, SchemaWithType, Walker, defaultPaginationKeywords, definePluginConfig, utils } from "@hey-api/shared"; import ts from "typescript"; import { AnyString, LazyOrAsync, MaybeArray, MaybeFunc } from "@hey-api/types"; import { HttpClient, HttpErrorResponse, HttpHeaders, HttpRequest, HttpResponse } from "@angular/common/http"; import { Injector } from "@angular/core"; import { AxiosError, AxiosInstance, AxiosRequestHeaders, AxiosResponse, AxiosStatic, CreateAxiosDefaults } from "axios"; import { AsyncDataOptions, UseFetchOptions, useAsyncData, useFetch, useLazyAsyncData, useLazyFetch } from "nuxt/app"; import { Ref as Ref$1 } from "vue"; import { FetchOptions, ResponseType, ofetch } from "ofetch"; import ky, { Options } from "ky"; import { LinguistLanguages, OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from "@hey-api/spec-types"; //#region src/plugins/@angular/common/httpRequests/types.d.ts interface UserHttpRequestsConfig { /** * Type of container for grouped operations. * * Ignored when `strategy` is `'flat'`. * * - `'class'` - Class with methods * * @default 'class' */ container?: 'class'; /** * Customize container names. * * For `'single'` strategy, this sets the root container name. * For `'byTags'` strategy, this transforms tag names. * * @default 'Sdk' for `'single'` strategy * * @example * // Set root name for single strategy * containerName: 'MyApi' * * @example * // Transform tag names with suffix * containerName: '{{name}}Service' * * @example * // With casing * containerName: { name: '{{name}}Service', case: 'PascalCase' } */ containerName?: NamingRule; /** * Whether this feature is enabled. * * @default true */ enabled?: boolean; /** * Customize method/function names. * * Applied to the final segment of the path (the method name). */ methodName?: NamingRule; /** * How methods are attached to class containers. * * Only applies when `container` is `'class'`. * * - `'instance'` - Instance methods, requires `new ClassName(config)` * * @default 'instance' */ methods?: 'instance'; /** * How to derive nesting structure from operations. * * - `'operationId'` - Split operationId by delimiters (e.g., `users.list` → `Users.list()`) * - `'id'` - Use operation id as-is, no nesting * - Custom function for full control * * @default 'operationId' */ nesting?: 'operationId' | 'id' | OperationPathStrategy; /** * Delimiters for splitting operationId. * * Only applies when `nesting` is `'operationId'`. * * @default /[./]/ */ nestingDelimiters?: RegExp; /** * Customize nesting segment names. * * Applied to intermediate path segments (not the method name). */ segmentName?: NamingRule; /** * Grouping strategy. * * - `'flat'` - Standalone functions, no grouping * - `'byTags'` - One container per operation tag * - `'single'` - All operations in one container * - Custom function for full control * * @default 'flat' */ strategy?: OperationsStrategy; /** * Default container name for operations without tags. * * Only applies when `strategy` is `'byTags'`. * * @default 'default' */ strategyDefaultTag?: string; } type HttpRequestsConfig = FeatureToggle & { /** * Type of container for grouped operations. * * Ignored when `strategy` is `'flat'`. * * - `'class'` - Class with methods */ container: 'class'; /** * Customize container names. * * For `'single'` strategy, this sets the root container name. * For `'byTags'` strategy, this transforms tag names. * * @default 'Sdk' for `'single'` strategy * * @example * // Set root name for single strategy * containerName: 'MyApi' * * @example * // Transform tag names with suffix * containerName: '{{name}}Service' * * @example * // With casing * containerName: { name: '{{name}}Service', case: 'PascalCase' } */ containerName: NamingConfig; /** * Customize method/function names. * * Applied to the final segment of the path (the method name). */ methodName: NamingConfig; /** * How methods are attached to class containers. * * Only applies when `container` is `'class'`. * * - `'instance'` - Instance methods, requires `new ClassName(config)` */ methods: 'instance'; /** * How to derive nesting structure from operations. * * - `'operationId'` - Split operationId by delimiters (e.g., `users.list` → `Users.list()`) * - `'id'` - Use operation id as-is, no nesting * - Custom function for full control */ nesting: 'operationId' | 'id' | OperationPathStrategy; /** * Delimiters for splitting operationId. * * Only applies when `nesting` is `'operationId'`. */ nestingDelimiters: RegExp; /** * Customize nesting segment names. * * Applied to intermediate path segments (not the method name). */ segmentName: NamingConfig; /** * Grouping strategy. * * - `'flat'` - Standalone functions, no grouping * - `'byTags'` - One container per operation tag * - `'single'` - All operations in one container * - Custom function for full control */ strategy: OperationsStrategy; /** * Default container name for operations without tags. * * Only applies when `strategy` is `'byTags'`. */ strategyDefaultTag: string; }; //#endregion //#region src/plugins/@angular/common/httpResources/types.d.ts interface UserHttpResourcesConfig { /** * Type of container for grouped operations. * * Ignored when `strategy` is `'flat'`. * * - `'class'` - Class with methods * * @default 'class' */ container?: 'class'; /** * Customize container names. * * For `'single'` strategy, this sets the root container name. * For `'byTags'` strategy, this transforms tag names. * * @default 'Sdk' for `'single'` strategy * * @example * // Set root name for single strategy * containerName: 'MyApi' * * @example * // Transform tag names with suffix * containerName: '{{name}}Service' * * @example * // With casing * containerName: { name: '{{name}}Service', case: 'PascalCase' } */ containerName?: NamingRule; /** * Whether this feature is enabled. * * @default true */ enabled?: boolean; /** * Customize method/function names. * * Applied to the final segment of the path (the method name). */ methodName?: NamingRule; /** * How methods are attached to class containers. * * Only applies when `container` is `'class'`. * * - `'instance'` - Instance methods, requires `new ClassName(config)` * * @default 'instance' */ methods?: 'instance'; /** * How to derive nesting structure from operations. * * - `'operationId'` - Split operationId by delimiters (e.g., `users.list` → `Users.list()`) * - `'id'` - Use operation id as-is, no nesting * - Custom function for full control * * @default 'operationId' */ nesting?: 'operationId' | 'id' | OperationPathStrategy; /** * Delimiters for splitting operationId. * * Only applies when `nesting` is `'operationId'`. * * @default /[./]/ */ nestingDelimiters?: RegExp; /** * Customize nesting segment names. * * Applied to intermediate path segments (not the method name). */ segmentName?: NamingRule; /** * Grouping strategy. * * - `'flat'` - Standalone functions, no grouping * - `'byTags'` - One container per operation tag * - `'single'` - All operations in one container * - Custom function for full control * * @default 'flat' */ strategy?: OperationsStrategy; /** * Default container name for operations without tags. * * Only applies when `strategy` is `'byTags'`. * * @default 'default' */ strategyDefaultTag?: string; } type HttpResourcesConfig = FeatureToggle & { /** * Type of container for grouped operations. * * Ignored when `strategy` is `'flat'`. * * - `'class'` - Class with methods */ container: 'class'; /** * Customize container names. * * For `'single'` strategy, this sets the root container name. * For `'byTags'` strategy, this transforms tag names. * * @default 'Sdk' for `'single'` strategy * * @example * // Set root name for single strategy * containerName: 'MyApi' * * @example * // Transform tag names with suffix * containerName: '{{name}}Service' * * @example * // With casing * containerName: { name: '{{name}}Service', case: 'PascalCase' } */ containerName: NamingConfig; /** * Customize method/function names. * * Applied to the final segment of the path (the method name). */ methodName: NamingConfig; /** * How methods are attached to class containers. * * Only applies when `container` is `'class'`. * * - `'instance'` - Instance methods, requires `new ClassName(config)` */ methods: 'instance'; /** * How to derive nesting structure from operations. * * - `'operationId'` - Split operationId by delimiters (e.g., `users.list` → `Users.list()`) * - `'id'` - Use operation id as-is, no nesting * - Custom function for full control */ nesting: 'operationId' | 'id' | OperationPathStrategy; /** * Delimiters for splitting operationId. * * Only applies when `nesting` is `'operationId'`. */ nestingDelimiters: RegExp; /** * Customize nesting segment names. * * Applied to intermediate path segments (not the method name). */ segmentName: NamingConfig; /** * Grouping strategy. * * - `'flat'` - Standalone functions, no grouping * - `'byTags'` - One container per operation tag * - `'single'` - All operations in one container * - Custom function for full control */ strategy: OperationsStrategy; /** * Default container name for operations without tags. * * Only applies when `strategy` is `'byTags'`. */ strategyDefaultTag: string; }; //#endregion //#region src/plugins/@angular/common/types.d.ts type UserConfig$27 = Plugin$1.Name<'@angular/common'> & Plugin$1.Hooks & Plugin$1.UserComments & Plugin$1.UserExports & { /** * Options for generating HTTP Request instances. * * @default 'flat' */ httpRequests?: boolean | OperationsStrategy | UserHttpRequestsConfig; /** * Options for generating HTTP resource APIs. * * @default 'flat' */ httpResources?: boolean | OperationsStrategy | UserHttpResourcesConfig; }; type Config$24 = Plugin$1.Name<'@angular/common'> & Plugin$1.Hooks & Plugin$1.Comments & Plugin$1.Exports & { /** * Options for generating HTTP Request instances. */ httpRequests: HttpRequestsConfig; /** * Options for generating HTTP resource APIs. */ httpResources: HttpResourcesConfig; }; type AngularCommonPlugin = DefinePlugin$1<UserConfig$27, Config$24>; //#endregion //#region src/ts-dsl/mixins/types.d.ts type BaseCtor<T extends ts.Node> = abstract new (...args: Array<any>) => TsDsl<T>; type DropFirst<T extends Array<any>> = T extends [any, ...infer Rest] ? Rest : never; type MixinCtor<T extends BaseCtor<any>, K> = abstract new (...args: Array<any>) => InstanceType<T> & K; //#endregion //#region src/ts-dsl/mixins/type-args.d.ts type Arg$1 = NodeName | MaybeTsDsl<TypeTsDsl>; interface TypeArgsMethods extends Node { /** Returns the type arguments as an array of ts.TypeNode nodes. */ $generics(): ReadonlyArray<ts.TypeNode> | undefined; /** Adds a single type argument (e.g., `string` in `Foo<string>`). */ generic(arg: Arg$1): this; /** Adds type arguments (e.g., `Map<string, number>`). */ generics(...args: ReadonlyArray<Arg$1>): this; } //#endregion //#region src/ts-dsl/mixins/type-returns.d.ts interface TypeReturnsMethods extends Node { /** Returns the return type node. */ $returns(): ts.TypeNode | undefined; /** Sets the return type. */ returns(type: NodeName | TypeTsDsl): this; } //#endregion //#region src/ts-dsl/type/param.d.ts type TypeParamExpr = NodeName | boolean | MaybeTsDsl<TypeTsDsl>; declare const Mixed$56: abstract new () => TsDsl<ts.TypeParameterDeclaration>; declare class TypeParamTsDsl extends Mixed$56 { readonly '~dsl' = "TypeParamTsDsl"; scope: NodeScope; protected constraint?: Ref<TypeParamExpr>; protected defaultValue?: Ref<TypeParamExpr>; constructor(name?: NodeName, fn?: (name: TypeParamTsDsl) => void); analyze(ctx: AnalysisContext): void; /** Sets the parameter default value. */ default(value: TypeParamExpr): this; extends(constraint: TypeParamExpr): this; toAst(): ts.TypeParameterDeclaration; } //#endregion //#region src/ts-dsl/mixins/type-params.d.ts interface TypeParamsMethods extends Node { /** Returns the type parameters as an array of ts.TypeParameterDeclaration nodes. */ $generics(): ReadonlyArray<ts.TypeParameterDeclaration> | undefined; /** Adds a single type parameter (e.g., `T` in `Array<T>`). */ generic(...args: ConstructorParameters<typeof TypeParamTsDsl>): this; /** Adds type parameters (e.g., `Map<string, T>`). */ generics(...args: ReadonlyArray<NodeName | MaybeTsDsl<TypeParamTsDsl>>): this; } //#endregion //#region src/ts-dsl/mixins/modifiers.d.ts type Modifiers = { /** * Checks if the specified modifier is present. * * @param modifier - The modifier to check. * @returns True if the modifier is present, false otherwise. */ hasModifier(modifier: Modifier): boolean; modifiers: Array<ts.Modifier>; }; type Modifier = 'abstract' | 'async' | 'const' | 'declare' | 'default' | 'export' | 'override' | 'private' | 'protected' | 'public' | 'readonly' | 'static'; interface AbstractMethods extends Modifiers { /** * Adds the `abstract` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ abstract(condition?: boolean): this; } interface AsyncMethods extends Modifiers { /** * Adds the `async` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ async(condition?: boolean): this; } interface ConstMethods extends Modifiers { /** * Adds the `const` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ const(condition?: boolean): this; } interface DefaultMethods extends Modifiers { /** * Adds the `default` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ default(condition?: boolean): this; } interface ExportMethods extends Modifiers { /** * Adds the `export` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ export(condition?: boolean): this; } interface PrivateMethods extends Modifiers { /** * Adds the `private` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ private(condition?: boolean): this; } interface ProtectedMethods extends Modifiers { /** * Adds the `protected` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ protected(condition?: boolean): this; } interface PublicMethods extends Modifiers { /** * Adds the `public` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ public(condition?: boolean): this; } interface ReadonlyMethods extends Modifiers { /** * Adds the `readonly` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ readonly(condition?: boolean): this; } interface StaticMethods extends Modifiers { /** * Adds the `static` keyword modifier if the condition is true. * * @param condition - Whether to add the modifier (default: true). * @returns The target object for chaining. */ static(condition?: boolean): this; } //#endregion //#region src/ts-dsl/mixins/value.d.ts type ValueExpr = string | MaybeTsDsl<ts.Expression>; interface ValueMethods extends Node { $value(): ts.Expression | undefined; /** Sets the initializer expression (e.g., `= expr`). */ assign(expr: ValueExpr): this; } //#endregion //#region src/ts-dsl/mixins/pattern.d.ts interface PatternMethods extends Node { /** Renders the pattern into a `BindingName`. */ $pattern(): ts.BindingName | undefined; /** Defines an array binding pattern. */ array(...props: ReadonlyArray<string> | [ReadonlyArray<string>]): this; /** Defines an object binding pattern. */ object(...props: ReadonlyArray<MaybeArray<string> | Record<string, string>>): this; /** Adds a spread element (e.g., `...args`, `...options`) to the pattern. */ spread(name: string): this; } //#endregion //#region src/ts-dsl/mixins/optional.d.ts interface OptionalMethods extends Node { _optional?: boolean; /** Marks the node as optional when the condition is true. */ optional(condition?: boolean): this; /** Marks the node as required when the condition is true. */ required(condition?: boolean): this; } //#endregion //#region src/ts-dsl/mixins/decorator.d.ts interface DecoratorMethods extends Node { /** Renders the decorators into an array of `ts.Decorator`s. */ $decorators(): ReadonlyArray<ts.Decorator>; /** Adds a decorator (e.g., `@sealed({ in: 'root' })`). */ decorator(name: NodeName | MaybeTsDsl<ts.Expression>, ...args: ReadonlyArray<string | MaybeTsDsl<ts.Expression>>): this; } //#endregion //#region src/ts-dsl/decl/param.d.ts type ParamName = NodeName | ParamFn; type ParamFn = (p: ParamTsDsl) => void; type ParamCtor = (name: ParamName, fn?: ParamFn) => ParamTsDsl; declare const Mixed$55: MixinCtor<MixinCtor<MixinCtor<MixinCtor<abstract new () => TsDsl<ts.ParameterDeclaration>, ValueMethods>, PatternMethods>, OptionalMethods>, DecoratorMethods>; declare class ParamTsDsl extends Mixed$55 { readonly '~dsl' = "ParamTsDsl"; protected _type?: TypeTsDsl; constructor(name: ParamName, fn?: ParamFn); analyze(ctx: AnalysisContext): void; /** Returns true when all required builder calls are present. */ get isValid(): boolean; /** Sets the parameter type. */ type(node: NodeName | TypeTsDsl): this; toAst(): ts.ParameterDeclaration; $validate(): asserts this; private missingRequiredCalls; } //#endregion //#region src/ts-dsl/mixins/param.d.ts interface ParamMethods extends Node { /** Renders the parameters into an array of `ParameterDeclaration`s. */ $params(): ReadonlyArray<ts.ParameterDeclaration>; /** Adds a parameter. */ param(...args: Parameters<ParamCtor>): this; /** Adds multiple parameters. */ params(...params: ReadonlyArray<MaybeTsDsl<ts.ParameterDeclaration>>): this; } //#endregion //#region src/ts-dsl/layout/doc.d.ts type DocMaybeLazy<T> = ((ctx: TsDslContext) => T) | T; type DocFn = (d: DocTsDsl) => void; type DocLines = DocMaybeLazy<MaybeArray<string>>; declare class DocTsDsl extends TsDsl<ts.Node> { readonly '~dsl' = "DocTsDsl"; protected _lines: Array<DocLines>; constructor(lines?: DocLines, fn?: DocFn); analyze(ctx: AnalysisContext): void; add(lines: DocLines): this; apply<T extends ts.Node>(node: T): T; toAst(): ts.Identifier; } //#endregion //#region src/ts-dsl/mixins/doc.d.ts interface DocMethods extends Node { $docs<T extends ts.Node>(node: T): T; doc(lines?: DocLines, fn?: DocFn): this; } //#endregion //#region src/ts-dsl/mixins/do.d.ts type DoExpr = MaybeTsDsl<ts.Expression | ts.Statement>; interface DoMethods extends Node { /** Renders the collected `.do()` calls into an array of `Statement` nodes. */ $do(): ReadonlyArray<ts.Statement>; _do: Array<DoExpr>; /** Adds one or more expressions/statements to the body. */ do(...items: ReadonlyArray<DoExpr>): this; } //#endregion //#region src/ts-dsl/decl/method.d.ts type MethodCtor = (name: NodeName, fn?: (m: MethodTsDsl) => void) => MethodTsDsl; declare const Mixed$54: MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<abstract new () => TsDsl<ts.MethodDeclaration>, TypeReturnsMethods>, TypeParamsMethods>, StaticMethods>, PublicMethods>, ProtectedMethods>, PrivateMethods>, ParamMethods>, OptionalMethods>, DocMethods>, DoMethods>, DecoratorMethods>, AsyncMethods>, AbstractMethods>; declare class MethodTsDsl extends Mixed$54 { readonly '~dsl' = "MethodTsDsl"; readonly nameSanitizer: (name: string) => string; constructor(name: NodeName, fn?: (m: MethodTsDsl) => void); analyze(ctx: AnalysisContext): void; toAst(): ts.MethodDeclaration; } //#endregion //#region src/ts-dsl/mixins/expr.d.ts interface ExprMethods extends Node { /** Accesses a property on the current expression (e.g., `this.foo`). */ attr(...args: DropFirst<Parameters<typeof f.attr>>): ReturnType<typeof f.attr>; /** Awaits the current expression (e.g., `await expr`). */ await(): ReturnType<typeof f.await>; /** Calls the current expression (e.g., `fn(arg1, arg2)`). */ call(...args: DropFirst<Parameters<typeof f.call>>): ReturnType<typeof f.call>; /** Produces a `return` statement returning the current expression. */ return(): ReturnType<typeof f.return>; } //#endregion //#region src/ts-dsl/mixins/as.d.ts interface AsMethods extends Node { /** Creates an `as` type assertion expression (e.g., `value as Type`). */ as(...args: DropFirst<Parameters<typeof f.as>>): ReturnType<typeof f.as>; } //#endregion //#region src/ts-dsl/expr/as.d.ts type AsExpr = NodeName | MaybeTsDsl<ts.Expression>; type AsType = NodeName | TypeTsDsl; type AsCtor = (expr: AsExpr, type: AsType) => AsTsDsl; declare const Mixed$53: MixinCtor<MixinCtor<abstract new () => TsDsl<ts.AsExpression>, ExprMethods>, AsMethods>; declare class AsTsDsl extends Mixed$53 { readonly '~dsl' = "AsTsDsl"; protected expr: Ref<AsExpr>; protected type: Ref<AsType>; constructor(expr: AsExpr, type: AsType); analyze(ctx: AnalysisContext): void; toAst(): ts.AsExpression; } //#endregion //#region src/ts-dsl/expr/binary.d.ts type Expr$2 = NodeName | MaybeTsDsl<ts.Expression>; type Op$1 = Operator | ts.BinaryOperator; type Operator = '!=' | '!==' | '&&' | '*' | '+' | '-' | '/' | '<' | '<=' | '=' | '==' | '===' | '>' | '>=' | '??' | '??=' | '||'; declare const Mixed$52: MixinCtor<MixinCtor<abstract new () => TsDsl<ts.BinaryExpression>, ExprMethods>, AsMethods>; declare class BinaryTsDsl extends Mixed$52 { readonly '~dsl' = "BinaryTsDsl"; protected _base: Ref<Expr$2>; protected _expr?: Ref<Expr$2>; protected _op?: Op$1; constructor(base: Expr$2, op?: Op$1, expr?: Expr$2); analyze(ctx: AnalysisContext): void; /** Returns true when all required builder calls are present. */ get isValid(): boolean; /** Logical AND — `this && expr` */ and(expr: Expr$2): this; /** Creates an assignment expression (e.g., `this = expr`). */ assign(expr: Expr$2): this; /** Nullish coalescing — `this ?? expr` */ coalesce(expr: Expr$2): this; /** Division — `this / expr` */ div(expr: Expr$2): this; /** Strict equality — `this === expr` */ eq(expr: Expr$2): this; /** Greater than — `this > expr` */ gt(expr: Expr$2): this; /** Greater than or equal — `this >= expr` */ gte(expr: Expr$2): this; /** Loose equality — `this == expr` */ looseEq(expr: Expr$2): this; /** Loose inequality — `this != expr` */ looseNeq(expr: Expr$2): this; /** Less than — `this < expr` */ lt(expr: Expr$2): this; /** Less than or equal — `this <= expr` */ lte(expr: Expr$2): this; /** Subtraction — `this - expr` */ minus(expr: Expr$2): this; /** Strict inequality — `this !== expr` */ neq(expr: Expr$2): this; /** Nullish assignment — `this ??= expr` */ nullishAssign(expr: Expr$2): this; /** Logical OR — `this || expr` */ or(expr: Expr$2): this; /** Addition — `this + expr` */ plus(expr: Expr$2): this; /** Multiplication — `this * expr` */ times(expr: Expr$2): this; toAst(): ts.BinaryExpression; $validate(): asserts this is this & { _expr: Ref<Expr$2>; _op: Op$1; }; private missingRequiredCalls; /** Sets the binary operator and right-hand operand for this expression. */ private opAndExpr; private opToToken; } //#endregion //#region src/ts-dsl/mixins/operator.d.ts type Expr$1 = NodeName | MaybeTsDsl<ts.Expression>; interface OperatorMethods extends Node { /** Logical AND — `this && expr` */ and(expr: Expr$1): BinaryTsDsl; /** Creates an assignment expression (e.g., `this = expr`). */ assign(expr: Expr$1): BinaryTsDsl; /** Nullish coalescing — `this ?? expr` */ coalesce(expr: Expr$1): BinaryTsDsl; /** Division — `this / expr` */ div(expr: Expr$1): BinaryTsDsl; /** Strict equality — `this === expr` */ eq(expr: Expr$1): BinaryTsDsl; /** Greater than — `this > expr` */ gt(expr: Expr$1): BinaryTsDsl; /** Greater than or equal — `this >= expr` */ gte(expr: Expr$1): BinaryTsDsl; /** Loose equality — `this == expr` */ looseEq(expr: Expr$1): BinaryTsDsl; /** Loose inequality — `this != expr` */ looseNeq(expr: Expr$1): BinaryTsDsl; /** Less than — `this < expr` */ lt(expr: Expr$1): BinaryTsDsl; /** Less than or equal — `this <= expr` */ lte(expr: Expr$1): BinaryTsDsl; /** Subtraction — `this - expr` */ minus(expr: Expr$1): BinaryTsDsl; /** Strict inequality — `this !== expr` */ neq(expr: Expr$1): BinaryTsDsl; /** Nullish assignment — `this ??= expr` */ nullishAssign(expr: Expr$1): BinaryTsDsl; /** Logical OR — `this || expr` */ or(expr: Expr$1): BinaryTsDsl; /** Addition — `this + expr` */ plus(expr: Expr$1): BinaryTsDsl; /** Multiplication — `this * expr` */ times(expr: Expr$1): BinaryTsDsl; } //#endregion //#region src/ts-dsl/expr/attr.d.ts type AttrLeft = NodeName | MaybeTsDsl<ts.Expression>; type AttrCtor = (left: AttrLeft, right: NodeName) => AttrTsDsl; declare const Mixed$51: MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<abstract new () => TsDsl<ts.PropertyAccessExpression | ts.ElementAccessExpression>, SpreadMethods>, OptionalMethods>, OperatorMethods>, ExprMethods>, AsMethods>; declare class AttrTsDsl extends Mixed$51 { readonly '~dsl' = "AttrTsDsl"; protected _computed: boolean; protected _left: Ref<AttrLeft>; constructor(left: AttrLeft, right: NodeName); analyze(ctx: AnalysisContext): void; /** Use computed property access (e.g., `obj[expr]`)? */ computed(condition?: boolean): this; toAst(): ts.PropertyAccessExpression | ts.ElementAccessExpression; } //#endregion //#region src/ts-dsl/expr/await.d.ts type AwaitExpr = NodeName | MaybeTsDsl<ts.Expression>; type AwaitCtor = (expr: AwaitExpr) => AwaitTsDsl; declare const Mixed$50: MixinCtor<abstract new () => TsDsl<ts.AwaitExpression>, ExprMethods>; declare class AwaitTsDsl extends Mixed$50 { readonly '~dsl' = "AwaitTsDsl"; protected _awaitExpr: Ref<AwaitExpr>; constructor(expr: AwaitExpr); analyze(ctx: AnalysisContext): void; toAst(): ts.AwaitExpression; } //#endregion //#region src/ts-dsl/mixins/args.d.ts type Arg = NodeName | MaybeTsDsl<ts.Expression | ts.SpreadElement>; interface ArgsMethods extends Node { /** Renders the arguments into an array of `Expression`s or `SpreadElement`s. */ $args(): ReadonlyArray<ts.Expression | ts.SpreadElement>; /** Adds a single expression argument. */ arg(arg: Arg | undefined): this; /** Adds one or more expression arguments. */ args(...args: ReadonlyArray<Arg | undefined>): this; } //#endregion //#region src/ts-dsl/expr/new.d.ts type NewArgs = ReadonlyArray<NewExpr | undefined>; type NewExpr = NodeName | MaybeTsDsl<ts.Expression>; type NewCtor = (expr: NewExpr, ...args: NewArgs) => NewTsDsl; declare const Mixed$49: MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<abstract new () => TsDsl<ts.NewExpression>, TypeArgsMethods>, SpreadMethods>, ExprMethods>, AsMethods>, ArgsMethods>; declare class NewTsDsl extends Mixed$49 { readonly '~dsl' = "NewTsDsl"; protected _newExpr: Ref<NewExpr>; constructor(expr: NewExpr, ...args: NewArgs); analyze(ctx: AnalysisContext): void; toAst(): ts.NewExpression; } //#endregion //#region src/ts-dsl/expr/spread.d.ts type SpreadExpr = NodeName | MaybeTsDsl<ts.Expression>; type SpreadCtor = (expr: SpreadExpr) => SpreadTsDsl; declare const Mixed$48: abstract new () => TsDsl<ts.SpreadElement>; declare class SpreadTsDsl extends Mixed$48 { readonly '~dsl' = "SpreadTsDsl"; protected _expr: Ref<SpreadExpr>; constructor(expr: SpreadExpr); analyze(ctx: AnalysisContext): void; toAst(): ts.SpreadElement; } //#endregion //#region src/ts-dsl/expr/typeof.d.ts type TypeOfExpr = NodeName | MaybeTsDsl<ts.Expression>; type TypeOfExprCtor = (expr: TypeOfExpr) => TypeOfExprTsDsl; declare const Mixed$47: MixinCtor<abstract new () => TsDsl<ts.TypeOfExpression>, OperatorMethods>; declare class TypeOfExprTsDsl extends Mixed$47 { readonly '~dsl' = "TypeOfExprTsDsl"; protected _expr: TypeOfExpr; constructor(expr: TypeOfExpr); analyze(ctx: AnalysisContext): void; toAst(): ts.TypeOfExpression; } //#endregion //#region src/ts-dsl/stmt/return.d.ts type ReturnExpr = NodeName | MaybeTsDsl<ts.Expression>; type ReturnCtor = (expr?: ReturnExpr) => ReturnTsDsl; declare const Mixed$46: abstract new () => TsDsl<ts.ReturnStatement>; declare class ReturnTsDsl extends Mixed$46 { readonly '~dsl' = "ReturnTsDsl"; protected _returnExpr?: Ref<ReturnExpr>; constructor(expr?: ReturnExpr); analyze(ctx: AnalysisContext): void; toAst(): ts.ReturnStatement; } //#endregion //#region src/ts-dsl/mixins/type-expr.d.ts interface TypeExprMethods extends Node { /** Creates an indexed-access type (e.g., `Foo<T>[K]`). */ idx(this: Parameters<typeof f.type.idx>[0], ...args: DropFirst<Parameters<typeof f.type.idx>>): ReturnType<typeof f.type.idx>; /** Shorthand: builds `keyof T`. */ keyof(this: MaybeTsDsl<TypeTsDsl>): ReturnType<typeof f.type.operator>; /** Shorthand: builds `readonly T`. */ readonly(this: MaybeTsDsl<TypeTsDsl>): ReturnType<typeof f.type.operator>; /** Create a TypeExpr node representing ReturnType<this>. */ returnType(this: Parameters<typeof f.type.query>[0], ...args: DropFirst<Parameters<typeof f.type.query>>): ReturnType<typeof f.type.expr>; /** Create a TypeOfExpr node representing typeof this. */ typeofExpr(this: Parameters<typeof f.typeofExpr>[0], ...args: DropFirst<Parameters<typeof f.typeofExpr>>): ReturnType<typeof f.typeofExpr>; /** Create a TypeQuery node representing typeof this. */ typeofType(this: Parameters<typeof f.type.query>[0], ...args: DropFirst<Parameters<typeof f.type.query>>): ReturnType<typeof f.type.query>; /** Shorthand: builds `unique T`. */ unique(this: MaybeTsDsl<TypeTsDsl>): ReturnType<typeof f.type.operator>; } //#endregion //#region src/ts-dsl/type/attr.d.ts type Base$1 = NodeName | MaybeTsDsl<ts.EntityName>; type Right = NodeName | ts.Identifier; declare const Mixed$45: MixinCtor<abstract new () => TsDsl<ts.QualifiedName>, TypeExprMethods>; declare class TypeAttrTsDsl extends Mixed$45 { readonly '~dsl' = "TypeAttrTsDsl"; scope: NodeScope; protected _base?: Ref<Base$1>; protected _right: Ref<Right>; constructor(base: Base$1 | Ref<Base$1>, right: string | ts.Identifier); constructor(right: Right); analyze(ctx: AnalysisContext): void; /** Returns true when all required builder calls are present. */ get isValid(): boolean; base(base?: Base$1 | Ref<Base$1>): this; right(right: Right): this; toAst(): ts.QualifiedName; $validate(): asserts this is this & { _base: Ref<Base$1>; _right: Ref<Right>; }; private missingRequiredCalls; } //#endregion //#region src/ts-dsl/type/expr.d.ts type TypeExprExpr = NodeName | TypeAttrTsDsl; type TypeExprFn = (t: TypeExprTsDsl) => void; type TypeExprCtor = (nameOrFn?: NodeName | TypeExprFn, fn?: TypeExprFn) => TypeExprTsDsl; declare const Mixed$44: MixinCtor<MixinCtor<abstract new () => TsDsl<ts.TypeReferenceNode>, TypeExprMethods>, TypeArgsMethods>; declare class TypeExprTsDsl extends Mixed$44 { readonly '~dsl' = "TypeExprTsDsl"; scope: NodeScope; protected _exprInput?: Ref<TypeExprExpr>; constructor(); constructor(fn: TypeExprFn); constructor(name: NodeName); constructor(name: NodeName, fn?: TypeExprFn); analyze(ctx: AnalysisContext): void; /** Returns true when all required builder calls are present. */ get isValid(): boolean; /** Accesses a nested type (e.g., `Foo.Bar`). */ attr(right: string | ts.Identifier | TypeAttrTsDsl): this; toAst(): ts.TypeReferenceNode; $validate(): asserts this is this & { _exprInput: Ref<TypeExprExpr>; }; private missingRequiredCalls; } //#endregion //#region src/ts-dsl/type/idx.d.ts type Base = string | MaybeTsDsl<ts.TypeNode>; type Index = string | number | MaybeTsDsl<ts.TypeNode>; type TypeIdxCtor = (base: Base, index: Index) => TypeIdxTsDsl; declare const Mixed$43: MixinCtor<abstract new () => TsDsl<ts.IndexedAccessTypeNode>, TypeExprMethods>; declare class TypeIdxTsDsl extends Mixed$43 { readonly '~dsl' = "TypeIdxTsDsl"; scope: NodeScope; protected _base: Base; protected _index: Index; constructor(base: Base, index: Index); analyze(ctx: AnalysisContext): void; /** Returns true when all required builder calls are present. */ get isValid(): boolean; base(base: Base): this; index(index: Index): this; toAst(): ts.IndexedAccessTypeNode; $validate(): asserts this is this & { _base: Base; _index: Index; }; private missingRequiredCalls; } //#endregion //#region src/ts-dsl/type/operator.d.ts type Op = ts.SyntaxKind.KeyOfKeyword | ts.SyntaxKind.ReadonlyKeyword | ts.SyntaxKind.UniqueKeyword; type Type$3 = string | MaybeTsDsl<ts.TypeNode>; type TypeOperatorCtor = () => TypeOperatorTsDsl; declare const Mixed$42: abstract new () => TsDsl<ts.TypeOperatorNode>; /** * Builds a TypeScript `TypeOperatorNode`, such as: * * - `keyof T` * - `readonly U` * - `unique V` * * This DSL provides both a generic `.operator()` API and convenient * shorthand methods (`.keyof()`, `.readonly()`, `.unique()`). * * The node will throw during render if required fields are missing. */ declare class TypeOperatorTsDsl extends Mixed$42 { readonly '~dsl' = "TypeOperatorTsDsl"; scope: NodeScope; protected _op?: Op; protected _type?: Type$3; analyze(ctx: AnalysisContext): void; /** Shorthand: builds `keyof T`. */ keyof(type: Type$3): this; /** Sets the operator explicitly. */ operator(op: Op): this; /** Shorthand: builds `readonly T`. */ readonly(type: Type$3): this; /** Sets the target type of the operator. */ type(type: Type$3): this; /** Shorthand: builds `unique T`. */ unique(type: Type$3): this; toAst(): ts.TypeOperatorNode; /** Throws if required fields are not set. */ $validate(): asserts this is this & { _op: Op; _type: Type$3; }; private missingRequiredCalls; } //#endregion //#region src/ts-dsl/type/query.d.ts type TypeQueryExpr = NodeName | MaybeTsDsl<TypeTsDsl | ts.Expression>; type TypeQueryCtor = (expr: TypeQueryExpr) => TypeQueryTsDsl; declare const Mixed$41: MixinCtor<abstract new () => TsDsl<ts.TypeQueryNode>, TypeExprMethods>; declare class TypeQueryTsDsl extends Mixed$41 { readonly '~dsl' = "TypeQueryTsDsl"; scope: NodeScope; protected _expr: Ref<TypeQueryExpr>; constructor(expr: TypeQueryExpr); analyze(ctx: AnalysisContext): void; toAst(): ts.TypeQueryNode; } //#endregion //#region src/ts-dsl/type/tuple-member.d.ts type TypeTupleMemberCtor = (name: NodeName) => TypeTupleMemberTsDsl; declare const Mixed$40: MixinCtor<abstract new () => TsDsl<ts.NamedTupleMember>, OptionalMethods>; declare class TypeTupleMemberTsDsl extends Mixed$40 { readonly '~dsl' = "TypeTupleMemberTsDsl"; scope: NodeScope; protected _type?: Ref<NodeName | TypeTsDsl>; constructor(name: NodeName); analyze(ctx: AnalysisContext): void; /** Returns true when all required builder calls are present. */ get isValid(): boolean; type(node: NodeName | TypeTsDsl): this; toAst(): ts.NamedTupleMember; $validate(): asserts this; private missingRequiredCalls; } //#endregion //#region src/ts-dsl/utils/factories.d.ts type Ctor = (...args: Array<any>) => any; type Factory<T extends Ctor> = { (...args: Parameters<T>): ReturnType<T>; /** Sets the implementation of this factory. */ set(fn: T): void; }; declare const f: { /** Factory for creating `as` type assertion expressions (e.g., `value as Type`). */as: Factory<AsCtor>; /** Factory for creating property access expressions (e.g., `obj.foo`). */ attr: Factory<AttrCtor>; /** Factory for creating await expressions (e.g., `await promise`). */ await: Factory<AwaitCtor>; /** Factory for creating function or method call expressions (e.g., `fn(arg)`). */ call: Factory<CallCtor>; /** Factory for creating method declarations (e.g., `{ foo() { ... } }`). */ method: Factory<MethodCtor>; /** Factory for creating new expressions (e.g., `new ClassName()`). */ new: Factory<NewCtor>; /** Factory for creating return statements. */ return: Factory<ReturnCtor>; /** Factory for creating spread expressions (e.g., `...expr`). */ spread: Factory<SpreadCtor>; /** Factories for creating type nodes. */ type: { /** Factory for creating basic type references or type expressions (e.g., Foo or Foo<T>). */expr: Factory<TypeExprCtor>; /** Factory for creating indexed-access types (e.g., `Foo<T>[K]`). */ idx: Factory<TypeIdxCtor>; /** Factory for creating type operator nodes (e.g., `readonly T`, `keyof T`, `unique T`). */ operator: Factory<TypeOperatorCtor>; /** Factory for creating type query nodes (e.g., `typeof Foo`). */ query: Factory<TypeQueryCtor>; /** Factory for creating named tuple elements (e.g., `[resolver?: R]`). */ tupleMember: Factory<TypeTupleMemberCtor>; }; /** Factory for creating `typeof` expressions (e.g., `typeof value`). */ typeofExpr: Factory<TypeOfExprCtor>; }; //#endregion //#region src/ts-dsl/mixins/spread.d.ts interface SpreadMethods extends Node { /** Produces a spread element from the current expression (e.g., `...expr`). */ spread(): ReturnType<typeof f.spread>; } //#endregion //#region src/ts-dsl/expr/call.d.ts type CallArgs = ReadonlyArray<CallCallee | undefined>; type CallCallee = NodeName | MaybeTsDsl<ts.Expression>; type CallCtor = (callee: CallCallee, ...args: CallArgs) => CallTsDsl; declare const Mixed$39: MixinCtor<MixinCtor<MixinCtor<MixinCtor<MixinCtor<abstract new () => TsDsl<ts.CallExpression>, TypeArgsMethods>, SpreadMethods>, ExprMethods>, AsMethods>, ArgsMethods>; declare class CallTsDsl extends Mixed$39 { readonly '~dsl' = "CallTsDsl"; protected _callee: Ref<CallCallee>; constructor(callee: CallCallee, ...args: CallArgs); analyze(ctx: AnalysisContext): void; toAst(): ts.CallExpression; } //#endregion //#region src/ts-dsl/utils/context.d.ts type NodeChain = ReadonlyArray<TsDsl>; interface AccessOptions { /** The access context. */ context?: 'example'; /** Enable debug mode. */ debug?: boolean; /** Transform function for each node in the access chain. */ transform?: (node: TsDsl, index: number, chain: NodeChain) => TsDsl; } type AccessResult = ReturnType<typeof $.expr | typeof $.attr | typeof $.call | typeof $.new>; interface ExampleOptions { /** Import kind for the root node. */ importKind?: BindingKind; /** Import name for the root node. */ importName?: string; /** Setup to run before calling the example. */ importSetup?: MaybeFunc<(ctx: DollarTsDsl & { /** The imported expression. */node: TsDsl<ts.Expression>; }) => TsDsl<ts.Expression>>; /** Module to import from. */ moduleName?: string; /** Example request payload. */ payload?: MaybeFunc<(ctx: DollarTsDsl) => CallArgs | CallArgs[number]>; /** Variable name for setup node. */ setupName?: string; } declare class TsDslContext { /** * Build an expression for accessing the node. * * @param node - The node or symbol to build access for * @param options - Access options * @returns Expression for accessing the node * * @example * ```ts * ctx.access(node); // → Expression for accessing the node * ``` */ access<T = AccessResult>(node: TsDsl | Symbol<TsDsl>, options?: AccessOptions): T; /** * Build an example. * * @param node - The node to generate an example for * @param options - Example options * @returns Full example string * * @example * ```ts * ctx.example(node, { moduleName: 'my-sdk' }); // → Full example string * ``` */ example(node: TsDsl, options?: ExampleOptions, astOptions?: Parameters<typeof TypeScriptRenderer.astToString>[0]): string; } declare const ctx: TsDslContext; //#endregion //#region src/ts-dsl/base.d.ts declare abstract class TsDsl<T extends ts.Node = ts.Node> implements Node<T> { analyze(_: AnalysisContext): void; clone(): this; exported?: boolean; file?: File; get name(): Node['name']; readonly nameSanitizer?: NodeNameSanitizer; language: Language; parent?: Node; root: boolean; scope?: NodeScope; structuralChildren?: Map<TsDsl, NodeRelationship>; structuralParents?: Map<TsDsl, NodeRelationship>; symbol?: Symbol; toAst(): T; readonly '~brand' = "heyapi.node"; /** Branding property to identify the DSL class at runtime. */ abstract readonly '~dsl': AnyString; /** Conditionally applies a callback to this builder. */ $if<T extends TsDsl, V, R extends TsDsl = T>(this: T, value: V, ifTrue: (self: T, v: Exclude<V, false | null | undefined>) => R | void, ifFalse?: (self: T, v: Extract<V, false | null | undefined>) => R | void): R | T; $if<T extends TsDsl, V, R extends TsDsl = T>(this: T, value: V, ifTrue: (v: Exclude<V, false | null | undefined>) => R | void, ifFalse?: (v: Extract<V, false | null | undefined>) => R | void): R | T; $if<T extends TsDsl, V, R extends TsDsl = T>(this: T, value: V, ifTrue: () => R | void, ifFalse?: () => R | void): R | T; /** Access patterns for this node. */ toAccessNode?(node: this, options: AccessOptions, ctx: { /** The full chain. */chain: ReadonlyArray<TsDsl>; /** Position in the chain (0 = root). */ index: number; /** Is this the leaf node? */ isLeaf: boolean; /** Is this the root node? */ isRoot: boolean; /** Total length of the chain. */ length: number; }): TsDsl | undefined; protected $maybeId<T extends string | ts.Expression>(expr: T): T extends string ? ts.Identifier : T; protected $name(name: Ref<NodeName>): string; protected $node<I>(value: I): NodeOfMaybe<I>; protected $type<I>(value: I, args?: ReadonlyArray<ts.TypeNode>): TypeOfMaybe<I>; private _name?; /** Unwraps nested nodes into raw TypeScript AST. */ private unwrap; } type NodeOfMaybe<I> = undefined extends I ? NodeOf<NonNullable<FromRef<I>>> | undefined : NodeOf<FromRef<I>>; type NodeOf<I> = I extends ReadonlyArray<infer U> ? ReadonlyArray<U extends TsDsl<infer N> ? N : U> : I extends string ? ts.Expression : I extends TsDsl<infer N> ? N : I extends ts.Node ? I : never; type MaybeTsDsl<T> = T extends TsDsl<infer U> ? U | TsDsl<U> : T extends ts.Node ? T | TsDsl<T> : never; declare abstract class TypeTsDsl<T extends ts.LiteralTypeNode | ts.QualifiedName | ts.TypeElement | ts.TypeNode | ts.TypeParameterDeclaration = ts.TypeNode> extends TsDsl<T> {} type TypeOfMaybe<I> = undefined extends I ? TypeOf<NonNullable<FromRef<I>>> | undefined : TypeOf<FromRef<I>>; type TypeOf<I> = I extends ReadonlyArray<infer U> ? ReadonlyArray<TypeOf<U>> : I extends string ? ts.TypeNode : I extends boolean ? ts.LiteralTypeNode : I extends TsDsl<infer N> ? N : I extends ts.TypeNode ? I : never; //#endregion //#region src/ts-dsl/expr/postfix.d.ts type PostfixExpr = string | MaybeTsDsl<ts.Expression>; type PostfixOp = ts.PostfixUnaryOperator; declare const Mixed$38: abstract new () => TsDsl<ts.PostfixUnaryExpression>; declare class PostfixTsDsl extends Mixed$38 { readonly '~dsl' = "PostfixTsDsl"; protected _expr?: PostfixExpr; protected _op?: PostfixOp; constructor(expr?: PostfixExpr, op?: PostfixOp); analyze(ctx: AnalysisContext): void; /** Returns true when all required builder calls are present. */ get isValid(): boolean; /** Sets the operator to MinusMinusToken for decrement (`--`). */ dec(): this; /** Sets the operand (the expression being postfixed). */ expr(expr: PostfixExpr): this; /** Sets the operator to PlusPlusToken for increment (`++`). */ inc(): this; /** Sets the operator (e.g., `ts.SyntaxKind.PlusPlusToken` for `++`). */ op(op: PostfixOp): this; toAst(): ts.PostfixUnaryExpression; $validate(): asserts this is this & { _expr: PostfixExpr; _op: PostfixOp; }; private missingRequiredCalls; } //#endregion //#region src/ts-dsl/layout/hint.d.ts type HintMaybeLazy<T> = ((ctx: TsDslContext) => T) | T; type HintFn = (d: HintTsDsl) => void; type HintLines = HintMaybeLazy<MaybeArray<string>>; declare class HintTsDsl extends TsDsl<ts.Node> { readonly '~dsl' = "HintTsDsl"; protected _lines: Array<HintLines>; constructor(lines?: HintLines, fn?: HintFn); analyze(ctx: AnalysisContext): void; add(lines: HintLines): this; apply<T extends ts.Node>(node: T): T; toAst(): ts.Identifier; } //#endregion //#region src/ts-dsl/stmt/if.d.ts type IfCondition = NodeName | MaybeTsDsl<ts.Expression>; declare const Mixed$37: MixinCtor<abstract new () => TsDsl<ts.IfStatement>, DoMethods>; declare class IfTsDsl extends Mixed$37 { readonly '~dsl' = "IfTsDsl"; protected _condition?: IfCondition; protected _else?: Array<DoExpr>; constructor(condition?: IfCondition); analyze(ctx: AnalysisContext): void; /** Returns true when all required builder calls are present. */ get isValid(): boolean; condition(condition: IfCondition): this; otherwise(...items: Array<DoExpr>): this; toAst(): ts.IfStatement; $validate(): asserts this is this & { _condition: IfCondition; }; private missingRequiredCalls; } //#endregion //#region src/ts-dsl/utils/lazy.d.ts type LazyThunk<T extends ts.Node> = (ctx: TsDslContext) => TsDsl<T>; declare class LazyTsDsl<T extends ts.Node = ts.Node> extends TsDsl<T> { readonly '~dsl' = "LazyTsDsl"; private _thunk; private _result?; constructor(thunk: LazyThunk<T>); analyze(ctx: AnalysisContext): void; toResult(): TsDsl<T>; toAst(): T; } //#endregion //#region src/ts-compiler/nodes/kinds.d.ts declare enum TsNodeKind { Assignment = "Assignment", Identifier = "Identifier", Literal = "Literal", SourceFile = "SourceFile", VariableStatement = "VariableStatement" } //#endregion //#region src/ts-compiler/nodes/expressions/identifier.d.ts interface TsIdentifier extends TsNodeBase { kind: TsNodeKind.Identifier; text: string; } declare function createIdentifier(text: string, leadingComments?: ReadonlyArray<string>, trailingComments?: ReadonlyArray<string>): TsIdentifier; //#endregion //#region src/ts-compiler/nodes/expression.d.ts type TsExpression = TsIdentifier | TsLiteral; //#endregion //#region src/ts-compiler/nodes/statements/assignment.d.ts interface TsAssignment extends TsNodeBase { kind: TsNodeKind.Assignment; target: TsExpression; type?: TsExpression; value?: TsExpression; } declare function createAssignment(target: TsExpression, type?: TsExpression, value?: TsExpression, leadingComments?: ReadonlyArray<string>, trailingComments?: ReadonlyArray<string>): TsAssignment; //#endregion //#region src/ts-compiler/nodes/type.d.ts type TsType = never; //#endregion //#region src/ts-compiler/nodes/statements/var.d.ts type TsVariableKeyword = 'var' | 'let' | 'const'; interface TsVariableStatement extends TsNodeBase { initializer?: TsExpression; keyword: TsVariableKeyword; kind: TsNodeKind.VariableStatement; name: string; typeAnnotation?: TsType; } declare function createVariableStatement(keyword: TsVariableKeyword, name: string, initializer?: TsExpression, typeAnnotation?: TsType, leadingComments?: ReadonlyArray<string>, trailingComments?: ReadonlyArray<string>): TsVariableStatement; //#endregion //#region src/ts-compiler/nodes/statement.d.ts type TsStatement = TsAssignment | TsVariableStatement; //#endregion //#region src/ts-compiler/nodes/structure/sourceFile.d.ts interface TsSourceFile extends TsNodeBase { kind: TsNodeKind.SourceFile; statements: ReadonlyArray<TsNode>; } declare function createSourceFile(statements: ReadonlyArray<TsNode>, leadingComments?: ReadonlyArray<string>, trailingComments?: ReadonlyArray<string>): TsSourceFile; //#endregion //#region src/ts-compiler/nodes/base.d.ts interface TsNodeBase { kind: TsNodeKind; leadingComments?: