@kubb/parser-ts 4.1.4 → 5.0.0-alpha.31

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.
@@ -1,249 +0,0 @@
1
- import { __export } from "./chunk-CTAAG5j7.js";
2
- import { isNumber } from "remeda";
3
- import ts from "typescript";
4
-
5
- //#region src/factory.ts
6
- var factory_exports = /* @__PURE__ */ __export({
7
- appendJSDocToNode: () => appendJSDocToNode,
8
- createArrayDeclaration: () => createArrayDeclaration,
9
- createArrayTypeNode: () => createArrayTypeNode,
10
- createEnumDeclaration: () => createEnumDeclaration,
11
- createExportDeclaration: () => createExportDeclaration,
12
- createFalse: () => createFalse,
13
- createIdentifier: () => createIdentifier,
14
- createImportDeclaration: () => createImportDeclaration,
15
- createIndexSignature: () => createIndexSignature,
16
- createInterfaceDeclaration: () => createInterfaceDeclaration,
17
- createIntersectionDeclaration: () => createIntersectionDeclaration,
18
- createJSDoc: () => createJSDoc,
19
- createLiteralTypeNode: () => createLiteralTypeNode,
20
- createNamespaceDeclaration: () => createNamespaceDeclaration,
21
- createNull: () => createNull,
22
- createNumericLiteral: () => createNumericLiteral,
23
- createOmitDeclaration: () => createOmitDeclaration,
24
- createOptionalTypeNode: () => createOptionalTypeNode,
25
- createParameterSignature: () => createParameterSignature,
26
- createPropertySignature: () => createPropertySignature,
27
- createQuestionToken: () => createQuestionToken,
28
- createRestTypeNode: () => createRestTypeNode,
29
- createStringLiteral: () => createStringLiteral,
30
- createTrue: () => createTrue,
31
- createTupleDeclaration: () => createTupleDeclaration,
32
- createTupleTypeNode: () => createTupleTypeNode,
33
- createTypeAliasDeclaration: () => createTypeAliasDeclaration,
34
- createTypeDeclaration: () => createTypeDeclaration,
35
- createTypeLiteralNode: () => createTypeLiteralNode,
36
- createTypeReferenceNode: () => createTypeReferenceNode,
37
- createUnionDeclaration: () => createUnionDeclaration,
38
- keywordTypeNodes: () => keywordTypeNodes,
39
- modifiers: () => modifiers,
40
- syntaxKind: () => syntaxKind
41
- });
42
- const { SyntaxKind, factory } = ts;
43
- const modifiers = {
44
- async: factory.createModifier(ts.SyntaxKind.AsyncKeyword),
45
- export: factory.createModifier(ts.SyntaxKind.ExportKeyword),
46
- const: factory.createModifier(ts.SyntaxKind.ConstKeyword),
47
- static: factory.createModifier(ts.SyntaxKind.StaticKeyword)
48
- };
49
- const syntaxKind = { union: SyntaxKind.UnionType };
50
- function isValidIdentifier(str) {
51
- if (!str.length || str.trim() !== str) return false;
52
- const node = ts.parseIsolatedEntityName(str, ts.ScriptTarget.Latest);
53
- return !!node && node.kind === ts.SyntaxKind.Identifier && ts.identifierToKeywordKind(node.kind) === void 0;
54
- }
55
- function propertyName(name) {
56
- if (typeof name === "string") return isValidIdentifier(name) ? factory.createIdentifier(name) : factory.createStringLiteral(name);
57
- return name;
58
- }
59
- const questionToken = factory.createToken(ts.SyntaxKind.QuestionToken);
60
- function createQuestionToken(token) {
61
- if (!token) return;
62
- if (token === true) return questionToken;
63
- return token;
64
- }
65
- function createIntersectionDeclaration({ nodes, withParentheses }) {
66
- if (!nodes.length) return null;
67
- if (nodes.length === 1) return nodes[0] || null;
68
- const node = factory.createIntersectionTypeNode(nodes);
69
- if (withParentheses) return factory.createParenthesizedType(node);
70
- return node;
71
- }
72
- /**
73
- * Minimum nodes length of 2
74
- * @example `string & number`
75
- */
76
- function createTupleDeclaration({ nodes, withParentheses }) {
77
- if (!nodes.length) return null;
78
- if (nodes.length === 1) return nodes[0] || null;
79
- const node = factory.createTupleTypeNode(nodes);
80
- if (withParentheses) return factory.createParenthesizedType(node);
81
- return node;
82
- }
83
- function createArrayDeclaration({ nodes }) {
84
- if (!nodes.length) return factory.createTupleTypeNode([]);
85
- if (nodes.length === 1) return factory.createArrayTypeNode(nodes.at(0));
86
- return factory.createExpressionWithTypeArguments(factory.createIdentifier("Array"), [factory.createUnionTypeNode(nodes)]);
87
- }
88
- /**
89
- * Minimum nodes length of 2
90
- * @example `string | number`
91
- */
92
- function createUnionDeclaration({ nodes, withParentheses }) {
93
- if (!nodes.length) return keywordTypeNodes.any;
94
- if (nodes.length === 1) return nodes[0];
95
- const node = factory.createUnionTypeNode(nodes);
96
- if (withParentheses) return factory.createParenthesizedType(node);
97
- return node;
98
- }
99
- function createPropertySignature({ readOnly, modifiers: modifiers$1 = [], name, questionToken: questionToken$1, type }) {
100
- return factory.createPropertySignature([...modifiers$1, readOnly ? factory.createToken(ts.SyntaxKind.ReadonlyKeyword) : void 0].filter(Boolean), propertyName(name), createQuestionToken(questionToken$1), type);
101
- }
102
- function createParameterSignature(name, { modifiers: modifiers$1, dotDotDotToken, questionToken: questionToken$1, type, initializer }) {
103
- return factory.createParameterDeclaration(modifiers$1, dotDotDotToken, name, createQuestionToken(questionToken$1), type, initializer);
104
- }
105
- function createJSDoc({ comments }) {
106
- if (!comments.length) return null;
107
- return factory.createJSDocComment(factory.createNodeArray(comments.map((comment, i) => {
108
- if (i === comments.length - 1) return factory.createJSDocText(comment);
109
- return factory.createJSDocText(`${comment}\n`);
110
- })));
111
- }
112
- /**
113
- * @link https://github.com/microsoft/TypeScript/issues/44151
114
- */
115
- function appendJSDocToNode({ node, comments }) {
116
- const filteredComments = comments.filter(Boolean);
117
- if (!filteredComments.length) return node;
118
- const text = filteredComments.reduce((acc = "", comment = "") => {
119
- return `${acc}\n * ${comment.replaceAll("*/", "*\\/")}`;
120
- }, "*");
121
- return ts.addSyntheticLeadingComment({ ...node }, ts.SyntaxKind.MultiLineCommentTrivia, `${text || "*"}\n`, true);
122
- }
123
- function createIndexSignature(type, { modifiers: modifiers$1, indexName = "key", indexType = factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword) } = {}) {
124
- return factory.createIndexSignature(modifiers$1, [createParameterSignature(indexName, { type: indexType })], type);
125
- }
126
- function createTypeAliasDeclaration({ modifiers: modifiers$1, name, typeParameters, type }) {
127
- return factory.createTypeAliasDeclaration(modifiers$1, name, typeParameters, type);
128
- }
129
- function createInterfaceDeclaration({ modifiers: modifiers$1, name, typeParameters, members }) {
130
- return factory.createInterfaceDeclaration(modifiers$1, name, typeParameters, void 0, members);
131
- }
132
- function createTypeDeclaration({ syntax, isExportable, comments, name, type }) {
133
- if (syntax === "interface" && "members" in type) {
134
- const node$1 = createInterfaceDeclaration({
135
- members: type.members,
136
- modifiers: isExportable ? [modifiers.export] : [],
137
- name,
138
- typeParameters: void 0
139
- });
140
- return appendJSDocToNode({
141
- node: node$1,
142
- comments
143
- });
144
- }
145
- const node = createTypeAliasDeclaration({
146
- type,
147
- modifiers: isExportable ? [modifiers.export] : [],
148
- name,
149
- typeParameters: void 0
150
- });
151
- return appendJSDocToNode({
152
- node,
153
- comments
154
- });
155
- }
156
- function createNamespaceDeclaration({ statements, name }) {
157
- return factory.createModuleDeclaration([factory.createToken(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier(name), factory.createModuleBlock(statements), ts.NodeFlags.Namespace);
158
- }
159
- /**
160
- * In { propertyName: string; name?: string } is `name` being used to make the type more unique when multiple same names are used.
161
- * @example `import { Pet as Cat } from './Pet'`
162
- */
163
- function createImportDeclaration({ name, path, isTypeOnly = false, isNameSpace = false }) {
164
- if (!Array.isArray(name)) {
165
- let importPropertyName = factory.createIdentifier(name);
166
- let importName;
167
- if (isNameSpace) {
168
- importPropertyName = void 0;
169
- importName = factory.createNamespaceImport(factory.createIdentifier(name));
170
- }
171
- return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, importPropertyName, importName), factory.createStringLiteral(path), void 0);
172
- }
173
- return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamedImports(name.map((item) => {
174
- if (typeof item === "object") {
175
- const obj = item;
176
- if (obj.name) return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name));
177
- return factory.createImportSpecifier(false, void 0, factory.createIdentifier(obj.propertyName));
178
- }
179
- return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
180
- }))), factory.createStringLiteral(path), void 0);
181
- }
182
- function createExportDeclaration({ path, asAlias, isTypeOnly = false, name }) {
183
- if (name && !Array.isArray(name) && !asAlias) console.warn(`When using name as string, asAlias should be true ${name}`);
184
- if (!Array.isArray(name)) {
185
- const parsedName = name?.match(/^\d/) ? `_${name?.slice(1)}` : name;
186
- return factory.createExportDeclaration(void 0, isTypeOnly, asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0, factory.createStringLiteral(path), void 0);
187
- }
188
- return factory.createExportDeclaration(void 0, isTypeOnly, factory.createNamedExports(name.map((propertyName$1) => {
189
- return factory.createExportSpecifier(false, void 0, typeof propertyName$1 === "string" ? factory.createIdentifier(propertyName$1) : propertyName$1);
190
- })), factory.createStringLiteral(path), void 0);
191
- }
192
- function createEnumDeclaration({ type = "enum", name, typeName, enums }) {
193
- if (type === "literal") return [void 0, factory.createTypeAliasDeclaration([factory.createToken(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier(typeName), void 0, factory.createUnionTypeNode(enums.map(([_key, value]) => {
194
- if (isNumber(value)) return factory.createLiteralTypeNode(factory.createNumericLiteral(value?.toString()));
195
- if (typeof value === "boolean") return factory.createLiteralTypeNode(value ? factory.createTrue() : factory.createFalse());
196
- if (value) return factory.createLiteralTypeNode(factory.createStringLiteral(value.toString()));
197
- }).filter(Boolean)))];
198
- if (type === "enum" || type === "constEnum") return [void 0, factory.createEnumDeclaration([factory.createToken(ts.SyntaxKind.ExportKeyword), type === "constEnum" ? factory.createToken(ts.SyntaxKind.ConstKeyword) : void 0].filter(Boolean), factory.createIdentifier(typeName), enums.map(([key, value]) => {
199
- let initializer = factory.createStringLiteral(value?.toString());
200
- if (Number.parseInt(value.toString(), 10) === value && isNumber(Number.parseInt(value.toString(), 10))) initializer = factory.createNumericLiteral(value);
201
- if (typeof value === "boolean") initializer = value ? factory.createTrue() : factory.createFalse();
202
- if (isNumber(Number.parseInt(key.toString(), 10))) return factory.createEnumMember(factory.createStringLiteral(`${typeName}_${key}`), initializer);
203
- if (key) return factory.createEnumMember(factory.createStringLiteral(`${key}`), initializer);
204
- }).filter(Boolean))];
205
- const identifierName = type === "asPascalConst" ? typeName : name;
206
- return [factory.createVariableStatement([factory.createToken(ts.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier(identifierName), void 0, void 0, factory.createAsExpression(factory.createObjectLiteralExpression(enums.map(([key, value]) => {
207
- let initializer = factory.createStringLiteral(value?.toString());
208
- if (isNumber(value)) if (value < 0) initializer = factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)));
209
- else initializer = factory.createNumericLiteral(value);
210
- if (typeof value === "boolean") initializer = value ? factory.createTrue() : factory.createFalse();
211
- if (key) return factory.createPropertyAssignment(factory.createStringLiteral(`${key}`), initializer);
212
- }).filter(Boolean), true), factory.createTypeReferenceNode(factory.createIdentifier("const"), void 0)))], ts.NodeFlags.Const)), factory.createTypeAliasDeclaration(type === "asPascalConst" ? [] : [factory.createToken(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier(typeName), void 0, factory.createIndexedAccessTypeNode(factory.createParenthesizedType(factory.createTypeQueryNode(factory.createIdentifier(identifierName), void 0)), factory.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, factory.createTypeQueryNode(factory.createIdentifier(identifierName), void 0))))];
213
- }
214
- function createOmitDeclaration({ keys, type, nonNullable }) {
215
- const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier("NonNullable"), [type]) : type;
216
- if (Array.isArray(keys)) return factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [node, factory.createUnionTypeNode(keys.map((key) => {
217
- return factory.createLiteralTypeNode(factory.createStringLiteral(key));
218
- }))]);
219
- return factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [node, factory.createLiteralTypeNode(factory.createStringLiteral(keys))]);
220
- }
221
- const keywordTypeNodes = {
222
- any: factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
223
- unknown: factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword),
224
- void: factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword),
225
- number: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),
226
- integer: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),
227
- object: factory.createKeywordTypeNode(ts.SyntaxKind.ObjectKeyword),
228
- string: factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
229
- boolean: factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword),
230
- undefined: factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword),
231
- null: factory.createLiteralTypeNode(factory.createToken(ts.SyntaxKind.NullKeyword))
232
- };
233
- const createTypeLiteralNode = factory.createTypeLiteralNode;
234
- const createTypeReferenceNode = factory.createTypeReferenceNode;
235
- const createNumericLiteral = factory.createNumericLiteral;
236
- const createStringLiteral = factory.createStringLiteral;
237
- const createArrayTypeNode = factory.createArrayTypeNode;
238
- const createLiteralTypeNode = factory.createLiteralTypeNode;
239
- const createNull = factory.createNull;
240
- const createIdentifier = factory.createIdentifier;
241
- const createOptionalTypeNode = factory.createOptionalTypeNode;
242
- const createTupleTypeNode = factory.createTupleTypeNode;
243
- const createRestTypeNode = factory.createRestTypeNode;
244
- const createTrue = factory.createTrue;
245
- const createFalse = factory.createFalse;
246
-
247
- //#endregion
248
- export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, factory_exports, keywordTypeNodes, modifiers, syntaxKind };
249
- //# sourceMappingURL=factory-CroRqsMR.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory-CroRqsMR.js","names":["modifiers","questionToken","node","importPropertyName: ts.Identifier | undefined","importName: ts.NamedImportBindings | undefined","propertyName","initializer: ts.Expression"],"sources":["../src/factory.ts"],"sourcesContent":["import { isNumber } from 'remeda'\nimport ts from 'typescript'\n\nconst { SyntaxKind, factory } = ts\n\n// https://ts-ast-viewer.com/\n\nexport const modifiers = {\n async: factory.createModifier(ts.SyntaxKind.AsyncKeyword),\n export: factory.createModifier(ts.SyntaxKind.ExportKeyword),\n const: factory.createModifier(ts.SyntaxKind.ConstKeyword),\n static: factory.createModifier(ts.SyntaxKind.StaticKeyword),\n} as const\n\nexport const syntaxKind = {\n union: SyntaxKind.UnionType as 192,\n} as const\n\nfunction isValidIdentifier(str: string): boolean {\n if (!str.length || str.trim() !== str) {\n return false\n }\n const node = ts.parseIsolatedEntityName(str, ts.ScriptTarget.Latest)\n\n return !!node && node.kind === ts.SyntaxKind.Identifier && ts.identifierToKeywordKind(node.kind as unknown as ts.Identifier) === undefined\n}\n\nfunction propertyName(name: string | ts.PropertyName): ts.PropertyName {\n if (typeof name === 'string') {\n return isValidIdentifier(name) ? factory.createIdentifier(name) : factory.createStringLiteral(name)\n }\n return name\n}\n\nconst questionToken = factory.createToken(ts.SyntaxKind.QuestionToken)\n\nexport function createQuestionToken(token?: boolean | ts.QuestionToken) {\n if (!token) {\n return undefined\n }\n if (token === true) {\n return questionToken\n }\n return token\n}\n\nexport function createIntersectionDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode | null {\n if (!nodes.length) {\n return null\n }\n\n if (nodes.length === 1) {\n return nodes[0] || null\n }\n\n const node = factory.createIntersectionTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\n/**\n * Minimum nodes length of 2\n * @example `string & number`\n */\nexport function createTupleDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode | null {\n if (!nodes.length) {\n return null\n }\n\n if (nodes.length === 1) {\n return nodes[0] || null\n }\n\n const node = factory.createTupleTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\nexport function createArrayDeclaration({ nodes }: { nodes: Array<ts.TypeNode> }): ts.TypeNode | null {\n if (!nodes.length) {\n return factory.createTupleTypeNode([])\n }\n\n if (nodes.length === 1) {\n return factory.createArrayTypeNode(nodes.at(0)!)\n }\n\n return factory.createExpressionWithTypeArguments(factory.createIdentifier('Array'), [factory.createUnionTypeNode(nodes)])\n}\n\n/**\n * Minimum nodes length of 2\n * @example `string | number`\n */\nexport function createUnionDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode {\n if (!nodes.length) {\n return keywordTypeNodes.any\n }\n\n if (nodes.length === 1) {\n return nodes[0] as ts.TypeNode\n }\n\n const node = factory.createUnionTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\nexport function createPropertySignature({\n readOnly,\n modifiers = [],\n name,\n questionToken,\n type,\n}: {\n readOnly?: boolean\n modifiers?: Array<ts.Modifier>\n name: ts.PropertyName | string\n questionToken?: ts.QuestionToken | boolean\n type?: ts.TypeNode\n}) {\n return factory.createPropertySignature(\n [...modifiers, readOnly ? factory.createToken(ts.SyntaxKind.ReadonlyKeyword) : undefined].filter(Boolean),\n propertyName(name),\n createQuestionToken(questionToken),\n type,\n )\n}\n\nexport function createParameterSignature(\n name: string | ts.BindingName,\n {\n modifiers,\n dotDotDotToken,\n questionToken,\n type,\n initializer,\n }: {\n decorators?: Array<ts.Decorator>\n modifiers?: Array<ts.Modifier>\n dotDotDotToken?: ts.DotDotDotToken\n questionToken?: ts.QuestionToken | boolean\n type?: ts.TypeNode\n initializer?: ts.Expression\n },\n): ts.ParameterDeclaration {\n return factory.createParameterDeclaration(modifiers, dotDotDotToken, name, createQuestionToken(questionToken), type, initializer)\n}\n\nexport function createJSDoc({ comments }: { comments: string[] }) {\n if (!comments.length) {\n return null\n }\n return factory.createJSDocComment(\n factory.createNodeArray(\n comments.map((comment, i) => {\n if (i === comments.length - 1) {\n return factory.createJSDocText(comment)\n }\n\n return factory.createJSDocText(`${comment}\\n`)\n }),\n ),\n )\n}\n\n/**\n * @link https://github.com/microsoft/TypeScript/issues/44151\n */\nexport function appendJSDocToNode<TNode extends ts.Node>({ node, comments }: { node: TNode; comments: Array<string | undefined> }) {\n const filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return node\n }\n\n const text = filteredComments.reduce((acc = '', comment = '') => {\n return `${acc}\\n * ${comment.replaceAll('*/', '*\\\\/')}`\n }, '*')\n\n // node: {...node}, with that ts.addSyntheticLeadingComment is appending\n return ts.addSyntheticLeadingComment({ ...node }, ts.SyntaxKind.MultiLineCommentTrivia, `${text || '*'}\\n`, true)\n}\n\nexport function createIndexSignature(\n type: ts.TypeNode,\n {\n modifiers,\n indexName = 'key',\n indexType = factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n }: {\n indexName?: string\n indexType?: ts.TypeNode\n decorators?: Array<ts.Decorator>\n modifiers?: Array<ts.Modifier>\n } = {},\n) {\n return factory.createIndexSignature(modifiers, [createParameterSignature(indexName, { type: indexType })], type)\n}\n\nexport function createTypeAliasDeclaration({\n modifiers,\n name,\n typeParameters,\n type,\n}: {\n modifiers?: Array<ts.Modifier>\n name: string | ts.Identifier\n typeParameters?: Array<ts.TypeParameterDeclaration>\n type: ts.TypeNode\n}) {\n return factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type)\n}\n\nexport function createInterfaceDeclaration({\n modifiers,\n name,\n typeParameters,\n members,\n}: {\n modifiers?: Array<ts.Modifier>\n name: string | ts.Identifier\n typeParameters?: Array<ts.TypeParameterDeclaration>\n members: Array<ts.TypeElement>\n}) {\n return factory.createInterfaceDeclaration(modifiers, name, typeParameters, undefined, members)\n}\n\nexport function createTypeDeclaration({\n syntax,\n isExportable,\n comments,\n name,\n type,\n}: {\n syntax: 'type' | 'interface'\n comments: Array<string | undefined>\n isExportable?: boolean\n name: string | ts.Identifier\n type: ts.TypeNode\n}) {\n if (syntax === 'interface' && 'members' in type) {\n const node = createInterfaceDeclaration({\n members: type.members as Array<ts.TypeElement>,\n modifiers: isExportable ? [modifiers.export] : [],\n name,\n typeParameters: undefined,\n })\n\n return appendJSDocToNode({\n node,\n comments,\n })\n }\n\n const node = createTypeAliasDeclaration({\n type,\n modifiers: isExportable ? [modifiers.export] : [],\n name,\n typeParameters: undefined,\n })\n\n return appendJSDocToNode({\n node,\n comments,\n })\n}\n\nexport function createNamespaceDeclaration({ statements, name }: { name: string; statements: ts.Statement[] }) {\n return factory.createModuleDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(name),\n factory.createModuleBlock(statements),\n ts.NodeFlags.Namespace,\n )\n}\n\n/**\n * In { propertyName: string; name?: string } is `name` being used to make the type more unique when multiple same names are used.\n * @example `import { Pet as Cat } from './Pet'`\n */\nexport function createImportDeclaration({\n name,\n path,\n isTypeOnly = false,\n isNameSpace = false,\n}: {\n name: string | Array<string | { propertyName: string; name?: string }>\n path: string\n isTypeOnly?: boolean\n isNameSpace?: boolean\n}) {\n if (!Array.isArray(name)) {\n let importPropertyName: ts.Identifier | undefined = factory.createIdentifier(name)\n let importName: ts.NamedImportBindings | undefined\n\n if (isNameSpace) {\n importPropertyName = undefined\n importName = factory.createNamespaceImport(factory.createIdentifier(name))\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, importPropertyName, importName),\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n name.map((item) => {\n if (typeof item === 'object') {\n const obj = item as { propertyName: string; name?: string }\n if (obj.name) {\n return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(obj.propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n }),\n ),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport function createExportDeclaration({\n path,\n asAlias,\n isTypeOnly = false,\n name,\n}: {\n path: string\n asAlias?: boolean\n isTypeOnly?: boolean\n name?: string | Array<ts.Identifier | string>\n}) {\n if (name && !Array.isArray(name) && !asAlias) {\n console.warn(`When using name as string, asAlias should be true ${name}`)\n }\n\n if (!Array.isArray(name)) {\n const parsedName = name?.match(/^\\d/) ? `_${name?.slice(1)}` : name\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : undefined,\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.map((propertyName) => {\n return factory.createExportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName)\n }),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport function createEnumDeclaration({\n type = 'enum',\n name,\n typeName,\n enums,\n}: {\n /**\n * @default `'enum'`\n */\n type?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'\n /**\n * Enum name in camelCase.\n */\n name: string\n /**\n * Enum name in PascalCase.\n */\n typeName: string\n enums: [key: string | number, value: string | number | boolean][]\n}): [name: ts.Node | undefined, type: ts.Node] {\n if (type === 'literal') {\n return [\n undefined,\n factory.createTypeAliasDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createUnionTypeNode(\n enums\n .map(([_key, value]) => {\n if (isNumber(value)) {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(value?.toString()))\n }\n\n if (typeof value === 'boolean') {\n return factory.createLiteralTypeNode(value ? factory.createTrue() : factory.createFalse())\n }\n if (value) {\n return factory.createLiteralTypeNode(factory.createStringLiteral(value.toString()))\n }\n\n return undefined\n })\n .filter(Boolean),\n ),\n ),\n ]\n }\n\n if (type === 'enum' || type === 'constEnum') {\n return [\n undefined,\n factory.createEnumDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword), type === 'constEnum' ? factory.createToken(ts.SyntaxKind.ConstKeyword) : undefined].filter(Boolean),\n factory.createIdentifier(typeName),\n enums\n .map(([key, value]) => {\n let initializer: ts.Expression = factory.createStringLiteral(value?.toString())\n const isExactNumber = Number.parseInt(value.toString(), 10) === value\n\n if (isExactNumber && isNumber(Number.parseInt(value.toString(), 10))) {\n initializer = factory.createNumericLiteral(value as number)\n }\n\n if (typeof value === 'boolean') {\n initializer = value ? factory.createTrue() : factory.createFalse()\n }\n\n if (isNumber(Number.parseInt(key.toString(), 10))) {\n return factory.createEnumMember(factory.createStringLiteral(`${typeName}_${key}`), initializer)\n }\n\n if (key) {\n return factory.createEnumMember(factory.createStringLiteral(`${key}`), initializer)\n }\n\n return undefined\n })\n .filter(Boolean),\n ),\n ]\n }\n\n // used when using `as const` instead of an TypeScript enum.\n const identifierName = type === 'asPascalConst' ? typeName : name\n\n return [\n factory.createVariableStatement(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n factory.createIdentifier(identifierName),\n undefined,\n undefined,\n factory.createAsExpression(\n factory.createObjectLiteralExpression(\n enums\n .map(([key, value]) => {\n let initializer: ts.Expression = factory.createStringLiteral(value?.toString())\n\n if (isNumber(value)) {\n // Error: Negative numbers should be created in combination with createPrefixUnaryExpression factory.\n // The method createNumericLiteral only accepts positive numbers\n // or those combined with createPrefixUnaryExpression.\n // Therefore, we need to ensure that the number is not negative.\n if (value < 0) {\n initializer = factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)))\n } else {\n initializer = factory.createNumericLiteral(value)\n }\n }\n\n if (typeof value === 'boolean') {\n initializer = value ? factory.createTrue() : factory.createFalse()\n }\n\n if (key) {\n return factory.createPropertyAssignment(factory.createStringLiteral(`${key}`), initializer)\n }\n\n return undefined\n })\n .filter(Boolean),\n true,\n ),\n factory.createTypeReferenceNode(factory.createIdentifier('const'), undefined),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n ),\n factory.createTypeAliasDeclaration(\n type === 'asPascalConst' ? [] : [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createIndexedAccessTypeNode(\n factory.createParenthesizedType(factory.createTypeQueryNode(factory.createIdentifier(identifierName), undefined)),\n factory.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, factory.createTypeQueryNode(factory.createIdentifier(identifierName), undefined)),\n ),\n ),\n ]\n}\n\nexport function createOmitDeclaration({ keys, type, nonNullable }: { keys: Array<string> | string; type: ts.TypeNode; nonNullable?: boolean }) {\n const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier('NonNullable'), [type]) : type\n\n if (Array.isArray(keys)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Omit'), [\n node,\n factory.createUnionTypeNode(\n keys.map((key) => {\n return factory.createLiteralTypeNode(factory.createStringLiteral(key))\n }),\n ),\n ])\n }\n\n return factory.createTypeReferenceNode(factory.createIdentifier('Omit'), [node, factory.createLiteralTypeNode(factory.createStringLiteral(keys))])\n}\n\nexport const keywordTypeNodes = {\n any: factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n unknown: factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword),\n void: factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword),\n number: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n integer: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n object: factory.createKeywordTypeNode(ts.SyntaxKind.ObjectKeyword),\n string: factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n boolean: factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword),\n undefined: factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword),\n null: factory.createLiteralTypeNode(factory.createToken(ts.SyntaxKind.NullKeyword)),\n} as const\n\nexport const createTypeLiteralNode = factory.createTypeLiteralNode\n\nexport const createTypeReferenceNode = factory.createTypeReferenceNode\nexport const createNumericLiteral = factory.createNumericLiteral\nexport const createStringLiteral = factory.createStringLiteral\n\nexport const createArrayTypeNode = factory.createArrayTypeNode\n\nexport const createLiteralTypeNode = factory.createLiteralTypeNode\nexport const createNull = factory.createNull\nexport const createIdentifier = factory.createIdentifier\n\nexport const createOptionalTypeNode = factory.createOptionalTypeNode\nexport const createTupleTypeNode = factory.createTupleTypeNode\nexport const createRestTypeNode = factory.createRestTypeNode\nexport const createTrue = factory.createTrue\nexport const createFalse = factory.createFalse\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,EAAE,YAAY,YAAY;AAIhC,MAAa,YAAY;CACvB,OAAO,QAAQ,eAAe,GAAG,WAAW,aAAa;CACzD,QAAQ,QAAQ,eAAe,GAAG,WAAW,cAAc;CAC3D,OAAO,QAAQ,eAAe,GAAG,WAAW,aAAa;CACzD,QAAQ,QAAQ,eAAe,GAAG,WAAW,cAAc;CAC5D;AAED,MAAa,aAAa,EACxB,OAAO,WAAW,WACnB;AAED,SAAS,kBAAkB,KAAsB;AAC/C,KAAI,CAAC,IAAI,UAAU,IAAI,MAAM,KAAK,IAChC,QAAO;CAET,MAAM,OAAO,GAAG,wBAAwB,KAAK,GAAG,aAAa,OAAO;AAEpE,QAAO,CAAC,CAAC,QAAQ,KAAK,SAAS,GAAG,WAAW,cAAc,GAAG,wBAAwB,KAAK,KAAiC,KAAK;;AAGnI,SAAS,aAAa,MAAiD;AACrE,KAAI,OAAO,SA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IAAI,CAAC;GACtE,CACH,CACF,CAAC;AAGJ,QAAO,QAAQ,wBAAwB,QAAQ,iBAAiB,OAAO,EAAE,CAAC,MAAM,QAAQ,sBAAsB,QAAQ,oBAAoB,KAAK,CAAC,CAAC,CAAC;;AAGpJ,MAAa,mBAAmB;CAC9B,KAAK,QAAQ,sBAAsB,GAAG,WAAW,WAAW;CAC5D,SAAS,QAAQ,sBAAsB,GAAG,WAAW,eAAe;CACpE,MAAM,QAAQ,sBAAsB,GAAG,WAAW,YAAY;CAC9D,QAAQ,QAAQ,sBAAsB,GAAG,WAAW,cAAc;CAClE,SAAS,QAAQ,sBAAsB,GAAG,WAAW,cAAc;CACnE,QAAQ,QAAQ,sBAAsB,GAAG,WAAW,cAAc;CAClE,QAAQ,QAAQ,sBAAsB,GAAG,WAAW,cAAc;CAClE,SAAS,QAAQ,sBAAsB,GAAG,WAAW,eAAe;CACpE,WAAW,QAAQ,sBAAsB,GAAG,WAAW,iBAAiB;CACxE,MAAM,QAAQ,sBAAsB,QAAQ,YAAY,GAAG,WAAW,YAAY,CAAC;CACpF;AAED,MAAa,wBAAwB,QAAQ;AAE7C,MAAa,0BAA0B,QAAQ;AAC/C,MAAa,uBAAuB,QAAQ;AAC5C,MAAa,sBAAsB,QAAQ;AAE3C,MAAa,sBAAsB,QAAQ;AAE3C,MAAa,wBAAwB,QAAQ;AAC7C,MAAa,aAAa,QAAQ;AAClC,MAAa,mBAAmB,QAAQ;AAExC,MAAa,yBAAyB,QAAQ;AAC9C,MAAa,sBAAsB,QAAQ;AAC3C,MAAa,qBAAqB,QAAQ;AAC1C,MAAa,aAAa,QAAQ;AAClC,MAAa,cAAc,QAAQ"}
@@ -1,227 +0,0 @@
1
- import ts from "typescript";
2
-
3
- //#region rolldown:runtime
4
- declare const modifiers: {
5
- readonly async: ts.ModifierToken<ts.SyntaxKind.AsyncKeyword>;
6
- readonly export: ts.ModifierToken<ts.SyntaxKind.ExportKeyword>;
7
- readonly const: ts.ModifierToken<ts.SyntaxKind.ConstKeyword>;
8
- readonly static: ts.ModifierToken<ts.SyntaxKind.StaticKeyword>;
9
- };
10
- declare const syntaxKind: {
11
- readonly union: 192;
12
- };
13
- declare function createQuestionToken(token?: boolean | ts.QuestionToken): ts.PunctuationToken<ts.SyntaxKind.QuestionToken> | undefined;
14
- declare function createIntersectionDeclaration({
15
- nodes,
16
- withParentheses
17
- }: {
18
- nodes: Array<ts.TypeNode>;
19
- withParentheses?: boolean;
20
- }): ts.TypeNode | null;
21
- /**
22
- * Minimum nodes length of 2
23
- * @example `string & number`
24
- */
25
- declare function createTupleDeclaration({
26
- nodes,
27
- withParentheses
28
- }: {
29
- nodes: Array<ts.TypeNode>;
30
- withParentheses?: boolean;
31
- }): ts.TypeNode | null;
32
- declare function createArrayDeclaration({
33
- nodes
34
- }: {
35
- nodes: Array<ts.TypeNode>;
36
- }): ts.TypeNode | null;
37
- /**
38
- * Minimum nodes length of 2
39
- * @example `string | number`
40
- */
41
- declare function createUnionDeclaration({
42
- nodes,
43
- withParentheses
44
- }: {
45
- nodes: Array<ts.TypeNode>;
46
- withParentheses?: boolean;
47
- }): ts.TypeNode;
48
- declare function createPropertySignature({
49
- readOnly,
50
- modifiers,
51
- name,
52
- questionToken,
53
- type
54
- }: {
55
- readOnly?: boolean;
56
- modifiers?: Array<ts.Modifier>;
57
- name: ts.PropertyName | string;
58
- questionToken?: ts.QuestionToken | boolean;
59
- type?: ts.TypeNode;
60
- }): ts.PropertySignature;
61
- declare function createParameterSignature(name: string | ts.BindingName, {
62
- modifiers,
63
- dotDotDotToken,
64
- questionToken,
65
- type,
66
- initializer
67
- }: {
68
- decorators?: Array<ts.Decorator>;
69
- modifiers?: Array<ts.Modifier>;
70
- dotDotDotToken?: ts.DotDotDotToken;
71
- questionToken?: ts.QuestionToken | boolean;
72
- type?: ts.TypeNode;
73
- initializer?: ts.Expression;
74
- }): ts.ParameterDeclaration;
75
- declare function createJSDoc({
76
- comments
77
- }: {
78
- comments: string[];
79
- }): ts.JSDoc | null;
80
- /**
81
- * @link https://github.com/microsoft/TypeScript/issues/44151
82
- */
83
- declare function appendJSDocToNode<TNode extends ts.Node>({
84
- node,
85
- comments
86
- }: {
87
- node: TNode;
88
- comments: Array<string | undefined>;
89
- }): TNode;
90
- declare function createIndexSignature(type: ts.TypeNode, {
91
- modifiers,
92
- indexName,
93
- indexType
94
- }?: {
95
- indexName?: string;
96
- indexType?: ts.TypeNode;
97
- decorators?: Array<ts.Decorator>;
98
- modifiers?: Array<ts.Modifier>;
99
- }): ts.IndexSignatureDeclaration;
100
- declare function createTypeAliasDeclaration({
101
- modifiers,
102
- name,
103
- typeParameters,
104
- type
105
- }: {
106
- modifiers?: Array<ts.Modifier>;
107
- name: string | ts.Identifier;
108
- typeParameters?: Array<ts.TypeParameterDeclaration>;
109
- type: ts.TypeNode;
110
- }): ts.TypeAliasDeclaration;
111
- declare function createInterfaceDeclaration({
112
- modifiers,
113
- name,
114
- typeParameters,
115
- members
116
- }: {
117
- modifiers?: Array<ts.Modifier>;
118
- name: string | ts.Identifier;
119
- typeParameters?: Array<ts.TypeParameterDeclaration>;
120
- members: Array<ts.TypeElement>;
121
- }): ts.InterfaceDeclaration;
122
- declare function createTypeDeclaration({
123
- syntax,
124
- isExportable,
125
- comments,
126
- name,
127
- type
128
- }: {
129
- syntax: 'type' | 'interface';
130
- comments: Array<string | undefined>;
131
- isExportable?: boolean;
132
- name: string | ts.Identifier;
133
- type: ts.TypeNode;
134
- }): ts.TypeAliasDeclaration | ts.InterfaceDeclaration;
135
- declare function createNamespaceDeclaration({
136
- statements,
137
- name
138
- }: {
139
- name: string;
140
- statements: ts.Statement[];
141
- }): ts.ModuleDeclaration;
142
- /**
143
- * In { propertyName: string; name?: string } is `name` being used to make the type more unique when multiple same names are used.
144
- * @example `import { Pet as Cat } from './Pet'`
145
- */
146
- declare function createImportDeclaration({
147
- name,
148
- path,
149
- isTypeOnly,
150
- isNameSpace
151
- }: {
152
- name: string | Array<string | {
153
- propertyName: string;
154
- name?: string;
155
- }>;
156
- path: string;
157
- isTypeOnly?: boolean;
158
- isNameSpace?: boolean;
159
- }): ts.ImportDeclaration;
160
- declare function createExportDeclaration({
161
- path,
162
- asAlias,
163
- isTypeOnly,
164
- name
165
- }: {
166
- path: string;
167
- asAlias?: boolean;
168
- isTypeOnly?: boolean;
169
- name?: string | Array<ts.Identifier | string>;
170
- }): ts.ExportDeclaration;
171
- declare function createEnumDeclaration({
172
- type,
173
- name,
174
- typeName,
175
- enums
176
- }: {
177
- /**
178
- * @default `'enum'`
179
- */
180
- type?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
181
- /**
182
- * Enum name in camelCase.
183
- */
184
- name: string;
185
- /**
186
- * Enum name in PascalCase.
187
- */
188
- typeName: string;
189
- enums: [key: string | number, value: string | number | boolean][];
190
- }): [name: ts.Node | undefined, type: ts.Node];
191
- declare function createOmitDeclaration({
192
- keys,
193
- type,
194
- nonNullable
195
- }: {
196
- keys: Array<string> | string;
197
- type: ts.TypeNode;
198
- nonNullable?: boolean;
199
- }): ts.TypeReferenceNode;
200
- declare const keywordTypeNodes: {
201
- readonly any: ts.KeywordTypeNode<ts.SyntaxKind.AnyKeyword>;
202
- readonly unknown: ts.KeywordTypeNode<ts.SyntaxKind.UnknownKeyword>;
203
- readonly void: ts.KeywordTypeNode<ts.SyntaxKind.VoidKeyword>;
204
- readonly number: ts.KeywordTypeNode<ts.SyntaxKind.NumberKeyword>;
205
- readonly integer: ts.KeywordTypeNode<ts.SyntaxKind.NumberKeyword>;
206
- readonly object: ts.KeywordTypeNode<ts.SyntaxKind.ObjectKeyword>;
207
- readonly string: ts.KeywordTypeNode<ts.SyntaxKind.StringKeyword>;
208
- readonly boolean: ts.KeywordTypeNode<ts.SyntaxKind.BooleanKeyword>;
209
- readonly undefined: ts.KeywordTypeNode<ts.SyntaxKind.UndefinedKeyword>;
210
- readonly null: ts.LiteralTypeNode;
211
- };
212
- declare const createTypeLiteralNode: (members: readonly ts.TypeElement[] | undefined) => ts.TypeLiteralNode;
213
- declare const createTypeReferenceNode: (typeName: string | ts.EntityName, typeArguments?: readonly ts.TypeNode[]) => ts.TypeReferenceNode;
214
- declare const createNumericLiteral: (value: string | number, numericLiteralFlags?: ts.TokenFlags) => ts.NumericLiteral;
215
- declare const createStringLiteral: (text: string, isSingleQuote?: boolean) => ts.StringLiteral;
216
- declare const createArrayTypeNode: (elementType: ts.TypeNode) => ts.ArrayTypeNode;
217
- declare const createLiteralTypeNode: (literal: ts.LiteralTypeNode["literal"]) => ts.LiteralTypeNode;
218
- declare const createNull: () => ts.NullLiteral;
219
- declare const createIdentifier: (text: string) => ts.Identifier;
220
- declare const createOptionalTypeNode: (type: ts.TypeNode) => ts.OptionalTypeNode;
221
- declare const createTupleTypeNode: (elements: readonly (ts.TypeNode | ts.NamedTupleMember)[]) => ts.TupleTypeNode;
222
- declare const createRestTypeNode: (type: ts.TypeNode) => ts.RestTypeNode;
223
- declare const createTrue: () => ts.TrueLiteral;
224
- declare const createFalse: () => ts.FalseLiteral;
225
- //#endregion
226
- export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, factory_d_exports, keywordTypeNodes, modifiers, syntaxKind };
227
- //# sourceMappingURL=factory-DqBZ_C7_.d.cts.map
package/dist/factory.cjs DELETED
@@ -1,36 +0,0 @@
1
- const require_factory = require('./factory-BNDICAoK.cjs');
2
-
3
- exports.appendJSDocToNode = require_factory.appendJSDocToNode;
4
- exports.createArrayDeclaration = require_factory.createArrayDeclaration;
5
- exports.createArrayTypeNode = require_factory.createArrayTypeNode;
6
- exports.createEnumDeclaration = require_factory.createEnumDeclaration;
7
- exports.createExportDeclaration = require_factory.createExportDeclaration;
8
- exports.createFalse = require_factory.createFalse;
9
- exports.createIdentifier = require_factory.createIdentifier;
10
- exports.createImportDeclaration = require_factory.createImportDeclaration;
11
- exports.createIndexSignature = require_factory.createIndexSignature;
12
- exports.createInterfaceDeclaration = require_factory.createInterfaceDeclaration;
13
- exports.createIntersectionDeclaration = require_factory.createIntersectionDeclaration;
14
- exports.createJSDoc = require_factory.createJSDoc;
15
- exports.createLiteralTypeNode = require_factory.createLiteralTypeNode;
16
- exports.createNamespaceDeclaration = require_factory.createNamespaceDeclaration;
17
- exports.createNull = require_factory.createNull;
18
- exports.createNumericLiteral = require_factory.createNumericLiteral;
19
- exports.createOmitDeclaration = require_factory.createOmitDeclaration;
20
- exports.createOptionalTypeNode = require_factory.createOptionalTypeNode;
21
- exports.createParameterSignature = require_factory.createParameterSignature;
22
- exports.createPropertySignature = require_factory.createPropertySignature;
23
- exports.createQuestionToken = require_factory.createQuestionToken;
24
- exports.createRestTypeNode = require_factory.createRestTypeNode;
25
- exports.createStringLiteral = require_factory.createStringLiteral;
26
- exports.createTrue = require_factory.createTrue;
27
- exports.createTupleDeclaration = require_factory.createTupleDeclaration;
28
- exports.createTupleTypeNode = require_factory.createTupleTypeNode;
29
- exports.createTypeAliasDeclaration = require_factory.createTypeAliasDeclaration;
30
- exports.createTypeDeclaration = require_factory.createTypeDeclaration;
31
- exports.createTypeLiteralNode = require_factory.createTypeLiteralNode;
32
- exports.createTypeReferenceNode = require_factory.createTypeReferenceNode;
33
- exports.createUnionDeclaration = require_factory.createUnionDeclaration;
34
- exports.keywordTypeNodes = require_factory.keywordTypeNodes;
35
- exports.modifiers = require_factory.modifiers;
36
- exports.syntaxKind = require_factory.syntaxKind;
@@ -1,2 +0,0 @@
1
- import { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind } from "./factory-DqBZ_C7_.cjs";
2
- export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind };
package/dist/factory.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind } from "./factory-BJCGLhSr.js";
2
- export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind };
package/dist/factory.js DELETED
@@ -1,3 +0,0 @@
1
- import { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind } from "./factory-CroRqsMR.js";
2
-
3
- export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind };
package/dist/index.d.cts DELETED
@@ -1,25 +0,0 @@
1
- import { factory_d_exports } from "./factory-DqBZ_C7_.cjs";
2
- import ts from "typescript";
3
-
4
- //#region src/format.d.ts
5
- declare function format(source?: string): Promise<string>;
6
- //#endregion
7
- //#region src/print.d.ts
8
- type PrintOptions = {
9
- source?: string;
10
- baseName?: string;
11
- scriptKind?: ts.ScriptKind;
12
- };
13
- /**
14
- * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
15
- * Ensures consistent output across environments.
16
- * Also works as a formatter when `source` is provided without `elements`.
17
- */
18
- declare function print(elements?: Array<ts.Node>, {
19
- source,
20
- baseName,
21
- scriptKind
22
- }?: PrintOptions): string;
23
- //#endregion
24
- export { factory_d_exports as factory, format, print };
25
- //# sourceMappingURL=index.d.cts.map