@kubb/plugin-ts 5.1.0-canary.20261024T075028 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,13 +1,233 @@
1
1
  import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
2
2
  import { KubbReactNode } from "kubb/jsx";
3
- import ts from "@typescript/typescript6";
3
+ declare namespace factory_d_exports {
4
+ export { TsNode, appendJSDocToNode, buildIndexSignatures, buildMemberNodes, buildPropertyType, buildTupleNode, constToTypeNode, createArrayDeclaration, createEnumDeclaration, createIntersectionDeclaration, createOmitDeclaration, createPropertySignature, createRaw, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, createUrlTemplateType, dateOrStringNode, isNonNullable, keywordTypeNodes, print, wrapNullableOptional };
5
+ }
6
+ /**
7
+ * A TS-ESTree node, the AST shape `yuku-codegen` prints. Nodes built here carry no source positions.
8
+ */
9
+ type TsNode = {
10
+ type: string;
11
+ [key: string]: unknown;
12
+ };
13
+ declare function isNonNullable<T>(value: T | null | undefined): value is T;
14
+ /**
15
+ * Prints `node` as TypeScript source with single quotes and two-space indentation.
16
+ */
17
+ declare function print(node: TsNode): string;
18
+ /**
19
+ * Wraps already printed TypeScript, such as a user override result, so it can sit inside a node tree.
20
+ * Parentheses keep a union or function type intact when it lands inside an array or intersection.
21
+ */
22
+ declare function createRaw(text: string): TsNode;
23
+ /**
24
+ * Creates a TypeScript intersection type.
25
+ * Returns the single type if only one is provided. `yuku-codegen` adds the parentheses a union member needs.
26
+ */
27
+ declare function createIntersectionDeclaration({ nodes, withParentheses }: {
28
+ nodes: Array<TsNode>;
29
+ withParentheses?: boolean;
30
+ }): TsNode | null;
31
+ /**
32
+ * Creates a TypeScript array type.
33
+ * Use `arrayType: 'array'` for bracket syntax (`T[]`), or `'generic'` for `Array<T>`.
34
+ *
35
+ * @example Array bracket syntax
36
+ * `createArrayDeclaration({ nodes: [string], arrayType: 'array' }) // → string[]`
37
+ *
38
+ * @example Generic Array syntax
39
+ * `createArrayDeclaration({ nodes: [string], arrayType: 'generic' }) // → Array<string>`
40
+ */
41
+ declare function createArrayDeclaration({ nodes, arrayType }: {
42
+ nodes: Array<TsNode>;
43
+ arrayType?: 'array' | 'generic';
44
+ }): TsNode;
45
+ /**
46
+ * Minimum nodes length of 2
47
+ * @example Union type example
48
+ * `string | number`
49
+ */
50
+ declare function createUnionDeclaration({ nodes, withParentheses }: {
51
+ nodes: Array<TsNode>;
52
+ withParentheses?: boolean;
53
+ }): TsNode;
54
+ /**
55
+ * Creates a TypeScript property signature for object/interface members.
56
+ * Supports optional markers, readonly modifiers, and type annotations.
57
+ */
58
+ declare function createPropertySignature({ readOnly, name, questionToken, type }: {
59
+ readOnly?: boolean;
60
+ name: string;
61
+ questionToken?: boolean;
62
+ type?: TsNode;
63
+ }): TsNode;
64
+ /**
65
+ * Attaches a JSDoc block built from `comments` to `node`, dropping empty comments.
66
+ */
67
+ declare function appendJSDocToNode<TNode extends TsNode>({ node, comments }: {
68
+ node: TNode;
69
+ comments: Array<string | undefined>;
70
+ }): TNode;
71
+ /**
72
+ * Creates a TypeScript type literal (anonymous object type) with one member per line.
73
+ */
74
+ declare function createTypeLiteralNode(members: Array<TsNode>): TsNode;
75
+ /**
76
+ * Creates a TypeScript type reference (e.g., `Array<string>`, `Record<K, V>`).
77
+ */
78
+ declare function createTypeReferenceNode(name: string, typeArguments?: Array<TsNode>): TsNode;
79
+ /**
80
+ * Prints a TypeScript type declaration as either a type alias or interface.
81
+ * Uses interface syntax only when requested and the type is an object literal, and attaches JSDoc comments.
82
+ */
83
+ declare function createTypeDeclaration({ syntax, isExportable, comments, name, type }: {
84
+ syntax: 'type' | 'interface';
85
+ comments: Array<string | undefined>;
86
+ isExportable?: boolean;
87
+ name: string;
88
+ type: TsNode;
89
+ }): string;
90
+ /**
91
+ * Creates a TypeScript enum declaration or equivalent construct in various formats.
92
+ * Returns a tuple of [name declaration, type declaration] - the name declaration may be undefined for certain types.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const [name, type] = createEnumDeclaration({
97
+ * type: 'enum',
98
+ * name: 'petType',
99
+ * typeName: 'PetType',
100
+ * enums: [['cat', 'cat', 'A cat'], ['dog', 'dog']],
101
+ * })
102
+ * ```
103
+ */
104
+ declare function createEnumDeclaration({ type, name, typeName, enums, enumKeyCasing }: {
105
+ /**
106
+ * Choose to use `enum`, `asConst`, `constEnum`, or `literal` for enums.
107
+ * - `enum`: TypeScript enum
108
+ * - `asConst`: const object asserted with `as const` (the caller decides the const name casing)
109
+ * - `constEnum`: const enum
110
+ * - `literal`: literal union type
111
+ * @default `'enum'`
112
+ */
113
+ type?: 'enum' | 'asConst' | 'constEnum' | 'literal' | 'inlineLiteral';
114
+ /**
115
+ * Enum name in camelCase.
116
+ */
117
+ name: string;
118
+ /**
119
+ * Enum name in PascalCase.
120
+ */
121
+ typeName: string;
122
+ enums: Array<[key: string | number, value: string | number | boolean, description?: string]>;
123
+ /**
124
+ * Choose the casing for enum key names.
125
+ * @default 'none'
126
+ */
127
+ enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
128
+ }): [name: string | undefined, type: string];
129
+ /**
130
+ * Creates a TypeScript `Omit<T, Keys>` type reference.
131
+ * Optionally wraps the type in `NonNullable<T>` if `nonNullable` is true.
132
+ */
133
+ declare function createOmitDeclaration({ keys, type, nonNullable }: {
134
+ keys: Array<string> | string;
135
+ type: TsNode;
136
+ nonNullable?: boolean;
137
+ }): TsNode;
138
+ /**
139
+ * TypeScript keyword types for common primitive types.
140
+ */
141
+ declare const keywordTypeNodes: {
142
+ readonly any: {
143
+ readonly type: 'TSAnyKeyword';
144
+ };
145
+ readonly unknown: {
146
+ readonly type: 'TSUnknownKeyword';
147
+ };
148
+ readonly void: {
149
+ readonly type: 'TSVoidKeyword';
150
+ };
151
+ readonly number: {
152
+ readonly type: 'TSNumberKeyword';
153
+ };
154
+ readonly integer: {
155
+ readonly type: 'TSNumberKeyword';
156
+ };
157
+ readonly bigint: {
158
+ readonly type: 'TSBigIntKeyword';
159
+ };
160
+ readonly object: {
161
+ readonly type: 'TSObjectKeyword';
162
+ };
163
+ readonly string: {
164
+ readonly type: 'TSStringKeyword';
165
+ };
166
+ readonly boolean: {
167
+ readonly type: 'TSBooleanKeyword';
168
+ };
169
+ readonly undefined: {
170
+ readonly type: 'TSUndefinedKeyword';
171
+ };
172
+ readonly null: {
173
+ readonly type: 'TSNullKeyword';
174
+ };
175
+ readonly never: {
176
+ readonly type: 'TSNeverKeyword';
177
+ };
178
+ };
179
+ /**
180
+ * Converts an OAS-style path (e.g. `/pets/{petId}`) or an Express-style path
181
+ * (e.g. `/pets/:petId`) to a TypeScript template literal type
182
+ * like `` `/pets/${string}` ``.
183
+ */
184
+ declare function createUrlTemplateType(path: string): TsNode;
185
+ /**
186
+ * Converts a primitive const value to a TypeScript literal type.
187
+ */
188
+ declare function constToTypeNode(value: string | number | boolean, format: 'string' | 'number' | 'boolean'): TsNode | undefined;
189
+ /**
190
+ * Returns a `Date` reference type when `representation` is `'date'`, otherwise falls back to `string`.
191
+ */
192
+ declare function dateOrStringNode(node: {
193
+ representation?: string;
194
+ }): TsNode;
195
+ /**
196
+ * Maps an array of `SchemaNode`s through the printer, filtering out `null` and `undefined` results.
197
+ */
198
+ declare function buildMemberNodes(members: Array<ast.SchemaNode> | undefined, print: (node: ast.SchemaNode) => TsNode | null | undefined): Array<TsNode>;
199
+ /**
200
+ * Builds a TypeScript tuple type from an array schema's `items`,
201
+ * applying min/max slice and optional/rest element rules.
202
+ */
203
+ declare function buildTupleNode(node: ast.ArraySchemaNode, print: (node: ast.SchemaNode) => TsNode | null | undefined): TsNode;
204
+ /**
205
+ * Appends `| null` and then `| undefined` to a type when requested.
206
+ */
207
+ declare function wrapNullableOptional(type: TsNode, nullable: boolean, addsUndefined: boolean): TsNode;
208
+ /**
209
+ * Applies `nullable` and optional/nullish `| undefined` union modifiers to a property's resolved base type.
210
+ */
211
+ declare function buildPropertyType(schema: ast.SchemaNode, baseType: TsNode, optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined', optional?: boolean): TsNode;
212
+ /**
213
+ * Creates a TypeScript index signature for `additionalProperties` and `patternProperties` on an
214
+ * object schema node. TypeScript allows only one string index signature and its value must be
215
+ * assignable from every named property, so both keywords collapse into a single signature: the
216
+ * union of all value types (deduplicated), or `unknown` when the object also has fixed properties.
217
+ * The key regex of `patternProperties` cannot be expressed by an index signature and is dropped.
218
+ */
219
+ declare function buildIndexSignatures(node: {
220
+ additionalProperties?: ast.SchemaNode | boolean;
221
+ patternProperties?: Record<string, ast.SchemaNode>;
222
+ }, propertyCount: number, printNode: (node: ast.SchemaNode) => TsNode | null | undefined): Array<TsNode>;
223
+ //#endregion
4
224
  //#region src/printers/printerTs.d.ts
5
225
  /**
6
226
  * Partial map of node-type overrides for the TypeScript printer.
7
227
  *
8
228
  * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`). The function
9
- * replaces the built-in handler for that node type. Use `this.transform` to
10
- * recurse into nested schema nodes, and `this.options` to read printer options.
229
+ * replaces the built-in handler for that node type and returns the TypeScript type as a string.
230
+ * Use `this.transform` to recurse into nested schema nodes, and `this.options` to read printer options.
11
231
  *
12
232
  * @example Override the `date` handler
13
233
  * ```ts
@@ -15,14 +235,18 @@ import ts from "@typescript/typescript6";
15
235
  * printer: {
16
236
  * nodes: {
17
237
  * date(node) {
18
- * return ts.factory.createTypeReferenceNode('Date', [])
238
+ * return 'Date'
19
239
  * },
20
240
  * },
21
241
  * },
22
242
  * })
23
243
  * ```
24
244
  */
25
- type PrinterTsNodes = ast.PrinterPartial<ts.TypeNode, PrinterTsOptions>;
245
+ type PrinterTsNodes = ast.PrinterPartial<string | DeprecatedTsNode, PrinterTsOptions>;
246
+ /** @deprecated A TypeScript compiler node returned by an override. Return a string; removed in the next major. */
247
+ type DeprecatedTsNode = {
248
+ readonly kind: number;
249
+ };
26
250
  type PrinterTsOptions = {
27
251
  /**
28
252
  * Mark parameters as optional with `?` or `| undefined`.
@@ -82,16 +306,16 @@ type PrinterTsOptions = {
82
306
  nodes?: PrinterTsNodes;
83
307
  };
84
308
  /**
85
- * TypeScript printer factory options: maps `SchemaNode` → `ts.TypeNode` (raw) or `ts.Node` (full declaration).
309
+ * TypeScript printer factory options: maps `SchemaNode` → a TS-ESTree node, printed to a type string or a full declaration string.
86
310
  */
87
- type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions, ts.TypeNode, string>;
311
+ type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions, TsNode, string>;
88
312
  /**
89
313
  * TypeScript type printer built with `definePrinter`.
90
314
  *
91
- * Converts a `SchemaNode` AST node into a TypeScript AST node:
92
- * - **`printer.print(node)`** — when `options.typeName` is set, returns a full
93
- * `type Name = …` or `interface Name { … }` declaration (`ts.Node`).
94
- * Without `typeName`, returns the raw `ts.TypeNode` for the schema.
315
+ * Converts a `SchemaNode` AST node into TypeScript source:
316
+ * - **`printer.print(node)`** — when `options.name` is set, returns a full
317
+ * `type Name = …` or `interface Name { … }` declaration.
318
+ * Without `name`, returns the type for the schema, such as `string | null`.
95
319
  *
96
320
  * Dispatches on `node.type` to the appropriate handler in `nodes`. Options are closed
97
321
  * over per printer instance, so each call to `printerTs(options)` produces an independent printer.
@@ -99,13 +323,13 @@ type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions
99
323
  * @example Raw type node (no `typeName`)
100
324
  * ```ts
101
325
  * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' } })
102
- * const typeNode = printer.print(schemaNode) // ts.TypeNode
326
+ * const type = printer.print(schemaNode) // 'string | null'
103
327
  * ```
104
328
  *
105
329
  * @example Full declaration (with `typeName`)
106
330
  * ```ts
107
331
  * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' }, typeName: 'MyType' })
108
- * const declaration = printer.print(schemaNode) // ts.TypeAliasDeclaration | ts.InterfaceDeclaration
332
+ * const declaration = printer.print(schemaNode) // 'export type MyType = …'
109
333
  * ```
110
334
  */
111
335
  export declare const printerTs: (options?: PrinterTsOptions | undefined) => ast.Printer<PrinterTsFactory>;
@@ -383,17 +607,16 @@ type Options = OutputOptions & {
383
607
  macros?: Array<ast.Macro>;
384
608
  /**
385
609
  * Replace the TypeScript handler for a specific schema type (`'integer'`, `'date'`, ...).
386
- * Each handler returns a TypeScript AST node for that schema type. Use `this.transform`
387
- * to recurse into nested schema nodes.
610
+ * Each handler returns the TypeScript type for that schema type as a string. Use `this.transform`
611
+ * to recurse into nested schema nodes. Returning a TypeScript compiler node is deprecated.
388
612
  *
389
613
  * @example Use the JavaScript `Date` object for date schemas
390
614
  * ```ts
391
- * import ts from '@typescript/typescript6'
392
615
  * pluginTs({
393
616
  * printer: {
394
617
  * nodes: {
395
618
  * date() {
396
- * return ts.factory.createTypeReferenceNode('Date', [])
619
+ * return 'Date'
397
620
  * },
398
621
  * },
399
622
  * },
package/dist/index.d.ts CHANGED
@@ -1,13 +1,233 @@
1
1
  import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
2
2
  import { KubbReactNode } from "kubb/jsx";
3
- import ts from "@typescript/typescript6";
3
+ declare namespace factory_d_exports {
4
+ export { TsNode, appendJSDocToNode, buildIndexSignatures, buildMemberNodes, buildPropertyType, buildTupleNode, constToTypeNode, createArrayDeclaration, createEnumDeclaration, createIntersectionDeclaration, createOmitDeclaration, createPropertySignature, createRaw, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, createUrlTemplateType, dateOrStringNode, isNonNullable, keywordTypeNodes, print, wrapNullableOptional };
5
+ }
6
+ /**
7
+ * A TS-ESTree node, the AST shape `yuku-codegen` prints. Nodes built here carry no source positions.
8
+ */
9
+ type TsNode = {
10
+ type: string;
11
+ [key: string]: unknown;
12
+ };
13
+ declare function isNonNullable<T>(value: T | null | undefined): value is T;
14
+ /**
15
+ * Prints `node` as TypeScript source with single quotes and two-space indentation.
16
+ */
17
+ declare function print(node: TsNode): string;
18
+ /**
19
+ * Wraps already printed TypeScript, such as a user override result, so it can sit inside a node tree.
20
+ * Parentheses keep a union or function type intact when it lands inside an array or intersection.
21
+ */
22
+ declare function createRaw(text: string): TsNode;
23
+ /**
24
+ * Creates a TypeScript intersection type.
25
+ * Returns the single type if only one is provided. `yuku-codegen` adds the parentheses a union member needs.
26
+ */
27
+ declare function createIntersectionDeclaration({ nodes, withParentheses }: {
28
+ nodes: Array<TsNode>;
29
+ withParentheses?: boolean;
30
+ }): TsNode | null;
31
+ /**
32
+ * Creates a TypeScript array type.
33
+ * Use `arrayType: 'array'` for bracket syntax (`T[]`), or `'generic'` for `Array<T>`.
34
+ *
35
+ * @example Array bracket syntax
36
+ * `createArrayDeclaration({ nodes: [string], arrayType: 'array' }) // → string[]`
37
+ *
38
+ * @example Generic Array syntax
39
+ * `createArrayDeclaration({ nodes: [string], arrayType: 'generic' }) // → Array<string>`
40
+ */
41
+ declare function createArrayDeclaration({ nodes, arrayType }: {
42
+ nodes: Array<TsNode>;
43
+ arrayType?: 'array' | 'generic';
44
+ }): TsNode;
45
+ /**
46
+ * Minimum nodes length of 2
47
+ * @example Union type example
48
+ * `string | number`
49
+ */
50
+ declare function createUnionDeclaration({ nodes, withParentheses }: {
51
+ nodes: Array<TsNode>;
52
+ withParentheses?: boolean;
53
+ }): TsNode;
54
+ /**
55
+ * Creates a TypeScript property signature for object/interface members.
56
+ * Supports optional markers, readonly modifiers, and type annotations.
57
+ */
58
+ declare function createPropertySignature({ readOnly, name, questionToken, type }: {
59
+ readOnly?: boolean;
60
+ name: string;
61
+ questionToken?: boolean;
62
+ type?: TsNode;
63
+ }): TsNode;
64
+ /**
65
+ * Attaches a JSDoc block built from `comments` to `node`, dropping empty comments.
66
+ */
67
+ declare function appendJSDocToNode<TNode extends TsNode>({ node, comments }: {
68
+ node: TNode;
69
+ comments: Array<string | undefined>;
70
+ }): TNode;
71
+ /**
72
+ * Creates a TypeScript type literal (anonymous object type) with one member per line.
73
+ */
74
+ declare function createTypeLiteralNode(members: Array<TsNode>): TsNode;
75
+ /**
76
+ * Creates a TypeScript type reference (e.g., `Array<string>`, `Record<K, V>`).
77
+ */
78
+ declare function createTypeReferenceNode(name: string, typeArguments?: Array<TsNode>): TsNode;
79
+ /**
80
+ * Prints a TypeScript type declaration as either a type alias or interface.
81
+ * Uses interface syntax only when requested and the type is an object literal, and attaches JSDoc comments.
82
+ */
83
+ declare function createTypeDeclaration({ syntax, isExportable, comments, name, type }: {
84
+ syntax: 'type' | 'interface';
85
+ comments: Array<string | undefined>;
86
+ isExportable?: boolean;
87
+ name: string;
88
+ type: TsNode;
89
+ }): string;
90
+ /**
91
+ * Creates a TypeScript enum declaration or equivalent construct in various formats.
92
+ * Returns a tuple of [name declaration, type declaration] - the name declaration may be undefined for certain types.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const [name, type] = createEnumDeclaration({
97
+ * type: 'enum',
98
+ * name: 'petType',
99
+ * typeName: 'PetType',
100
+ * enums: [['cat', 'cat', 'A cat'], ['dog', 'dog']],
101
+ * })
102
+ * ```
103
+ */
104
+ declare function createEnumDeclaration({ type, name, typeName, enums, enumKeyCasing }: {
105
+ /**
106
+ * Choose to use `enum`, `asConst`, `constEnum`, or `literal` for enums.
107
+ * - `enum`: TypeScript enum
108
+ * - `asConst`: const object asserted with `as const` (the caller decides the const name casing)
109
+ * - `constEnum`: const enum
110
+ * - `literal`: literal union type
111
+ * @default `'enum'`
112
+ */
113
+ type?: 'enum' | 'asConst' | 'constEnum' | 'literal' | 'inlineLiteral';
114
+ /**
115
+ * Enum name in camelCase.
116
+ */
117
+ name: string;
118
+ /**
119
+ * Enum name in PascalCase.
120
+ */
121
+ typeName: string;
122
+ enums: Array<[key: string | number, value: string | number | boolean, description?: string]>;
123
+ /**
124
+ * Choose the casing for enum key names.
125
+ * @default 'none'
126
+ */
127
+ enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
128
+ }): [name: string | undefined, type: string];
129
+ /**
130
+ * Creates a TypeScript `Omit<T, Keys>` type reference.
131
+ * Optionally wraps the type in `NonNullable<T>` if `nonNullable` is true.
132
+ */
133
+ declare function createOmitDeclaration({ keys, type, nonNullable }: {
134
+ keys: Array<string> | string;
135
+ type: TsNode;
136
+ nonNullable?: boolean;
137
+ }): TsNode;
138
+ /**
139
+ * TypeScript keyword types for common primitive types.
140
+ */
141
+ declare const keywordTypeNodes: {
142
+ readonly any: {
143
+ readonly type: 'TSAnyKeyword';
144
+ };
145
+ readonly unknown: {
146
+ readonly type: 'TSUnknownKeyword';
147
+ };
148
+ readonly void: {
149
+ readonly type: 'TSVoidKeyword';
150
+ };
151
+ readonly number: {
152
+ readonly type: 'TSNumberKeyword';
153
+ };
154
+ readonly integer: {
155
+ readonly type: 'TSNumberKeyword';
156
+ };
157
+ readonly bigint: {
158
+ readonly type: 'TSBigIntKeyword';
159
+ };
160
+ readonly object: {
161
+ readonly type: 'TSObjectKeyword';
162
+ };
163
+ readonly string: {
164
+ readonly type: 'TSStringKeyword';
165
+ };
166
+ readonly boolean: {
167
+ readonly type: 'TSBooleanKeyword';
168
+ };
169
+ readonly undefined: {
170
+ readonly type: 'TSUndefinedKeyword';
171
+ };
172
+ readonly null: {
173
+ readonly type: 'TSNullKeyword';
174
+ };
175
+ readonly never: {
176
+ readonly type: 'TSNeverKeyword';
177
+ };
178
+ };
179
+ /**
180
+ * Converts an OAS-style path (e.g. `/pets/{petId}`) or an Express-style path
181
+ * (e.g. `/pets/:petId`) to a TypeScript template literal type
182
+ * like `` `/pets/${string}` ``.
183
+ */
184
+ declare function createUrlTemplateType(path: string): TsNode;
185
+ /**
186
+ * Converts a primitive const value to a TypeScript literal type.
187
+ */
188
+ declare function constToTypeNode(value: string | number | boolean, format: 'string' | 'number' | 'boolean'): TsNode | undefined;
189
+ /**
190
+ * Returns a `Date` reference type when `representation` is `'date'`, otherwise falls back to `string`.
191
+ */
192
+ declare function dateOrStringNode(node: {
193
+ representation?: string;
194
+ }): TsNode;
195
+ /**
196
+ * Maps an array of `SchemaNode`s through the printer, filtering out `null` and `undefined` results.
197
+ */
198
+ declare function buildMemberNodes(members: Array<ast.SchemaNode> | undefined, print: (node: ast.SchemaNode) => TsNode | null | undefined): Array<TsNode>;
199
+ /**
200
+ * Builds a TypeScript tuple type from an array schema's `items`,
201
+ * applying min/max slice and optional/rest element rules.
202
+ */
203
+ declare function buildTupleNode(node: ast.ArraySchemaNode, print: (node: ast.SchemaNode) => TsNode | null | undefined): TsNode;
204
+ /**
205
+ * Appends `| null` and then `| undefined` to a type when requested.
206
+ */
207
+ declare function wrapNullableOptional(type: TsNode, nullable: boolean, addsUndefined: boolean): TsNode;
208
+ /**
209
+ * Applies `nullable` and optional/nullish `| undefined` union modifiers to a property's resolved base type.
210
+ */
211
+ declare function buildPropertyType(schema: ast.SchemaNode, baseType: TsNode, optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined', optional?: boolean): TsNode;
212
+ /**
213
+ * Creates a TypeScript index signature for `additionalProperties` and `patternProperties` on an
214
+ * object schema node. TypeScript allows only one string index signature and its value must be
215
+ * assignable from every named property, so both keywords collapse into a single signature: the
216
+ * union of all value types (deduplicated), or `unknown` when the object also has fixed properties.
217
+ * The key regex of `patternProperties` cannot be expressed by an index signature and is dropped.
218
+ */
219
+ declare function buildIndexSignatures(node: {
220
+ additionalProperties?: ast.SchemaNode | boolean;
221
+ patternProperties?: Record<string, ast.SchemaNode>;
222
+ }, propertyCount: number, printNode: (node: ast.SchemaNode) => TsNode | null | undefined): Array<TsNode>;
223
+ //#endregion
4
224
  //#region src/printers/printerTs.d.ts
5
225
  /**
6
226
  * Partial map of node-type overrides for the TypeScript printer.
7
227
  *
8
228
  * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`). The function
9
- * replaces the built-in handler for that node type. Use `this.transform` to
10
- * recurse into nested schema nodes, and `this.options` to read printer options.
229
+ * replaces the built-in handler for that node type and returns the TypeScript type as a string.
230
+ * Use `this.transform` to recurse into nested schema nodes, and `this.options` to read printer options.
11
231
  *
12
232
  * @example Override the `date` handler
13
233
  * ```ts
@@ -15,14 +235,18 @@ import ts from "@typescript/typescript6";
15
235
  * printer: {
16
236
  * nodes: {
17
237
  * date(node) {
18
- * return ts.factory.createTypeReferenceNode('Date', [])
238
+ * return 'Date'
19
239
  * },
20
240
  * },
21
241
  * },
22
242
  * })
23
243
  * ```
24
244
  */
25
- type PrinterTsNodes = ast.PrinterPartial<ts.TypeNode, PrinterTsOptions>;
245
+ type PrinterTsNodes = ast.PrinterPartial<string | DeprecatedTsNode, PrinterTsOptions>;
246
+ /** @deprecated A TypeScript compiler node returned by an override. Return a string; removed in the next major. */
247
+ type DeprecatedTsNode = {
248
+ readonly kind: number;
249
+ };
26
250
  type PrinterTsOptions = {
27
251
  /**
28
252
  * Mark parameters as optional with `?` or `| undefined`.
@@ -82,16 +306,16 @@ type PrinterTsOptions = {
82
306
  nodes?: PrinterTsNodes;
83
307
  };
84
308
  /**
85
- * TypeScript printer factory options: maps `SchemaNode` → `ts.TypeNode` (raw) or `ts.Node` (full declaration).
309
+ * TypeScript printer factory options: maps `SchemaNode` → a TS-ESTree node, printed to a type string or a full declaration string.
86
310
  */
87
- type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions, ts.TypeNode, string>;
311
+ type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions, TsNode, string>;
88
312
  /**
89
313
  * TypeScript type printer built with `definePrinter`.
90
314
  *
91
- * Converts a `SchemaNode` AST node into a TypeScript AST node:
92
- * - **`printer.print(node)`** — when `options.typeName` is set, returns a full
93
- * `type Name = …` or `interface Name { … }` declaration (`ts.Node`).
94
- * Without `typeName`, returns the raw `ts.TypeNode` for the schema.
315
+ * Converts a `SchemaNode` AST node into TypeScript source:
316
+ * - **`printer.print(node)`** — when `options.name` is set, returns a full
317
+ * `type Name = …` or `interface Name { … }` declaration.
318
+ * Without `name`, returns the type for the schema, such as `string | null`.
95
319
  *
96
320
  * Dispatches on `node.type` to the appropriate handler in `nodes`. Options are closed
97
321
  * over per printer instance, so each call to `printerTs(options)` produces an independent printer.
@@ -99,13 +323,13 @@ type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions
99
323
  * @example Raw type node (no `typeName`)
100
324
  * ```ts
101
325
  * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' } })
102
- * const typeNode = printer.print(schemaNode) // ts.TypeNode
326
+ * const type = printer.print(schemaNode) // 'string | null'
103
327
  * ```
104
328
  *
105
329
  * @example Full declaration (with `typeName`)
106
330
  * ```ts
107
331
  * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' }, typeName: 'MyType' })
108
- * const declaration = printer.print(schemaNode) // ts.TypeAliasDeclaration | ts.InterfaceDeclaration
332
+ * const declaration = printer.print(schemaNode) // 'export type MyType = …'
109
333
  * ```
110
334
  */
111
335
  export declare const printerTs: (options?: PrinterTsOptions | undefined) => ast.Printer<PrinterTsFactory>;
@@ -383,17 +607,16 @@ type Options = OutputOptions & {
383
607
  macros?: Array<ast.Macro>;
384
608
  /**
385
609
  * Replace the TypeScript handler for a specific schema type (`'integer'`, `'date'`, ...).
386
- * Each handler returns a TypeScript AST node for that schema type. Use `this.transform`
387
- * to recurse into nested schema nodes.
610
+ * Each handler returns the TypeScript type for that schema type as a string. Use `this.transform`
611
+ * to recurse into nested schema nodes. Returning a TypeScript compiler node is deprecated.
388
612
  *
389
613
  * @example Use the JavaScript `Date` object for date schemas
390
614
  * ```ts
391
- * import ts from '@typescript/typescript6'
392
615
  * pluginTs({
393
616
  * printer: {
394
617
  * nodes: {
395
618
  * date() {
396
- * return ts.factory.createTypeReferenceNode('Date', [])
619
+ * return 'Date'
397
620
  * },
398
621
  * },
399
622
  * },