@kubb/parser-ts 3.10.8 → 3.10.10
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/{chunk-3H6MBFVZ.cjs → chunk-XEWLBD2X.cjs} +9 -30
- package/dist/chunk-XEWLBD2X.cjs.map +1 -0
- package/dist/{chunk-7QFNR36N.js → chunk-ZNZX6QZO.js} +9 -30
- package/dist/chunk-ZNZX6QZO.js.map +1 -0
- package/dist/{factory-BeCWs14y.d.cts → factory-Cn6Avpxk.d.cts} +7 -7
- package/dist/{factory-BeCWs14y.d.ts → factory-Cn6Avpxk.d.ts} +7 -7
- package/dist/factory.cjs +35 -35
- package/dist/factory.d.cts +1 -1
- package/dist/factory.d.ts +1 -1
- package/dist/factory.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
- package/src/factory.ts +7 -49
- package/dist/chunk-3H6MBFVZ.cjs.map +0 -1
- package/dist/chunk-7QFNR36N.js.map +0 -1
|
@@ -84,10 +84,7 @@ function createQuestionToken(token) {
|
|
|
84
84
|
}
|
|
85
85
|
return token;
|
|
86
86
|
}
|
|
87
|
-
function createIntersectionDeclaration({
|
|
88
|
-
nodes,
|
|
89
|
-
withParentheses
|
|
90
|
-
}) {
|
|
87
|
+
function createIntersectionDeclaration({ nodes, withParentheses }) {
|
|
91
88
|
if (!nodes.length) {
|
|
92
89
|
return null;
|
|
93
90
|
}
|
|
@@ -100,10 +97,7 @@ function createIntersectionDeclaration({
|
|
|
100
97
|
}
|
|
101
98
|
return node;
|
|
102
99
|
}
|
|
103
|
-
function createTupleDeclaration({
|
|
104
|
-
nodes,
|
|
105
|
-
withParentheses
|
|
106
|
-
}) {
|
|
100
|
+
function createTupleDeclaration({ nodes, withParentheses }) {
|
|
107
101
|
if (!nodes.length) {
|
|
108
102
|
return null;
|
|
109
103
|
}
|
|
@@ -116,9 +110,7 @@ function createTupleDeclaration({
|
|
|
116
110
|
}
|
|
117
111
|
return node;
|
|
118
112
|
}
|
|
119
|
-
function createArrayDeclaration({
|
|
120
|
-
nodes
|
|
121
|
-
}) {
|
|
113
|
+
function createArrayDeclaration({ nodes }) {
|
|
122
114
|
if (!nodes.length) {
|
|
123
115
|
return factory.createTupleTypeNode([]);
|
|
124
116
|
}
|
|
@@ -127,10 +119,7 @@ function createArrayDeclaration({
|
|
|
127
119
|
}
|
|
128
120
|
return factory.createExpressionWithTypeArguments(factory.createIdentifier("Array"), [factory.createUnionTypeNode(nodes)]);
|
|
129
121
|
}
|
|
130
|
-
function createUnionDeclaration({
|
|
131
|
-
nodes,
|
|
132
|
-
withParentheses
|
|
133
|
-
}) {
|
|
122
|
+
function createUnionDeclaration({ nodes, withParentheses }) {
|
|
134
123
|
if (!nodes.length) {
|
|
135
124
|
return keywordTypeNodes.any;
|
|
136
125
|
}
|
|
@@ -182,10 +171,7 @@ function createJSDoc({ comments }) {
|
|
|
182
171
|
)
|
|
183
172
|
);
|
|
184
173
|
}
|
|
185
|
-
function appendJSDocToNode({
|
|
186
|
-
node,
|
|
187
|
-
comments
|
|
188
|
-
}) {
|
|
174
|
+
function appendJSDocToNode({ node, comments }) {
|
|
189
175
|
const filteredComments = comments.filter(Boolean);
|
|
190
176
|
if (!filteredComments.length) {
|
|
191
177
|
return node;
|
|
@@ -250,10 +236,7 @@ function createTypeDeclaration({
|
|
|
250
236
|
comments
|
|
251
237
|
});
|
|
252
238
|
}
|
|
253
|
-
function createNamespaceDeclaration({
|
|
254
|
-
statements,
|
|
255
|
-
name
|
|
256
|
-
}) {
|
|
239
|
+
function createNamespaceDeclaration({ statements, name }) {
|
|
257
240
|
return factory.createModuleDeclaration(
|
|
258
241
|
[factory.createToken(ts__default.default.SyntaxKind.ExportKeyword)],
|
|
259
242
|
factory.createIdentifier(name),
|
|
@@ -439,11 +422,7 @@ function createEnumDeclaration({
|
|
|
439
422
|
)
|
|
440
423
|
];
|
|
441
424
|
}
|
|
442
|
-
function createOmitDeclaration({
|
|
443
|
-
keys,
|
|
444
|
-
type,
|
|
445
|
-
nonNullable
|
|
446
|
-
}) {
|
|
425
|
+
function createOmitDeclaration({ keys, type, nonNullable }) {
|
|
447
426
|
const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier("NonNullable"), [type]) : type;
|
|
448
427
|
if (Array.isArray(keys)) {
|
|
449
428
|
return factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [
|
|
@@ -518,5 +497,5 @@ exports.factory_exports = factory_exports;
|
|
|
518
497
|
exports.keywordTypeNodes = keywordTypeNodes;
|
|
519
498
|
exports.modifiers = modifiers;
|
|
520
499
|
exports.syntaxKind = syntaxKind;
|
|
521
|
-
//# sourceMappingURL=chunk-
|
|
522
|
-
//# sourceMappingURL=chunk-
|
|
500
|
+
//# sourceMappingURL=chunk-XEWLBD2X.cjs.map
|
|
501
|
+
//# sourceMappingURL=chunk-XEWLBD2X.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/factory.ts"],"names":["ts","modifiers","questionToken","node","propertyName","isNumber"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA,eAAA,GAAA;AAAA,QAAA,CAAA,eAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,WAAA,EA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AA,OAAA,CAAQ,qBAAsB,CAAAA,mBAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EACjE,OAAS,EAAA,OAAA,CAAQ,qBAAsB,CAAAA,mBAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EAClE,MAAQ,EAAA,OAAA,CAAQ,qBAAsB,CAAAA,mBAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EACjE,MAAQ,EAAA,OAAA,CAAQ,qBAAsB,CAAAA,mBAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EACjE,OAAS,EAAA,OAAA,CAAQ,qBAAsB,CAAAA,mBAAA,CAAG,WAAW,cAAc,CAAA;AAAA,EACnE,SAAW,EAAA,OAAA,CAAQ,qBAAsB,CAAAA,mBAAA,CAAG,WAAW,gBAAgB,CAAA;AAAA,EACvE,IAAA,EAAM,QAAQ,qBAAsB,CAAA,OAAA,CAAQ,YAAYA,mBAAG,CAAA,UAAA,CAAW,WAAW,CAAC;AACpF;AAEO,IAAM,wBAAwB,OAAQ,CAAA;AAEtC,IAAM,0BAA0B,OAAQ,CAAA;AACxC,IAAM,uBAAuB,OAAQ,CAAA;AACrC,IAAM,sBAAsB,OAAQ,CAAA;AAEpC,IAAM,sBAAsB,OAAQ,CAAA;AAEpC,IAAM,wBAAwB,OAAQ,CAAA;AACtC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,mBAAmB,OAAQ,CAAA;AAEjC,IAAM,yBAAyB,OAAQ,CAAA;AACvC,IAAM,sBAAsB,OAAQ,CAAA;AACpC,IAAM,qBAAqB,OAAQ,CAAA;AACnC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,cAAc,OAAQ,CAAA","file":"chunk-XEWLBD2X.cjs","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 = 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()) === value\n\n if (isExactNumber && isNumber(Number.parseInt(value.toString()))) {\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()))) {\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"]}
|
|
@@ -78,10 +78,7 @@ function createQuestionToken(token) {
|
|
|
78
78
|
}
|
|
79
79
|
return token;
|
|
80
80
|
}
|
|
81
|
-
function createIntersectionDeclaration({
|
|
82
|
-
nodes,
|
|
83
|
-
withParentheses
|
|
84
|
-
}) {
|
|
81
|
+
function createIntersectionDeclaration({ nodes, withParentheses }) {
|
|
85
82
|
if (!nodes.length) {
|
|
86
83
|
return null;
|
|
87
84
|
}
|
|
@@ -94,10 +91,7 @@ function createIntersectionDeclaration({
|
|
|
94
91
|
}
|
|
95
92
|
return node;
|
|
96
93
|
}
|
|
97
|
-
function createTupleDeclaration({
|
|
98
|
-
nodes,
|
|
99
|
-
withParentheses
|
|
100
|
-
}) {
|
|
94
|
+
function createTupleDeclaration({ nodes, withParentheses }) {
|
|
101
95
|
if (!nodes.length) {
|
|
102
96
|
return null;
|
|
103
97
|
}
|
|
@@ -110,9 +104,7 @@ function createTupleDeclaration({
|
|
|
110
104
|
}
|
|
111
105
|
return node;
|
|
112
106
|
}
|
|
113
|
-
function createArrayDeclaration({
|
|
114
|
-
nodes
|
|
115
|
-
}) {
|
|
107
|
+
function createArrayDeclaration({ nodes }) {
|
|
116
108
|
if (!nodes.length) {
|
|
117
109
|
return factory.createTupleTypeNode([]);
|
|
118
110
|
}
|
|
@@ -121,10 +113,7 @@ function createArrayDeclaration({
|
|
|
121
113
|
}
|
|
122
114
|
return factory.createExpressionWithTypeArguments(factory.createIdentifier("Array"), [factory.createUnionTypeNode(nodes)]);
|
|
123
115
|
}
|
|
124
|
-
function createUnionDeclaration({
|
|
125
|
-
nodes,
|
|
126
|
-
withParentheses
|
|
127
|
-
}) {
|
|
116
|
+
function createUnionDeclaration({ nodes, withParentheses }) {
|
|
128
117
|
if (!nodes.length) {
|
|
129
118
|
return keywordTypeNodes.any;
|
|
130
119
|
}
|
|
@@ -176,10 +165,7 @@ function createJSDoc({ comments }) {
|
|
|
176
165
|
)
|
|
177
166
|
);
|
|
178
167
|
}
|
|
179
|
-
function appendJSDocToNode({
|
|
180
|
-
node,
|
|
181
|
-
comments
|
|
182
|
-
}) {
|
|
168
|
+
function appendJSDocToNode({ node, comments }) {
|
|
183
169
|
const filteredComments = comments.filter(Boolean);
|
|
184
170
|
if (!filteredComments.length) {
|
|
185
171
|
return node;
|
|
@@ -244,10 +230,7 @@ function createTypeDeclaration({
|
|
|
244
230
|
comments
|
|
245
231
|
});
|
|
246
232
|
}
|
|
247
|
-
function createNamespaceDeclaration({
|
|
248
|
-
statements,
|
|
249
|
-
name
|
|
250
|
-
}) {
|
|
233
|
+
function createNamespaceDeclaration({ statements, name }) {
|
|
251
234
|
return factory.createModuleDeclaration(
|
|
252
235
|
[factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
|
253
236
|
factory.createIdentifier(name),
|
|
@@ -433,11 +416,7 @@ function createEnumDeclaration({
|
|
|
433
416
|
)
|
|
434
417
|
];
|
|
435
418
|
}
|
|
436
|
-
function createOmitDeclaration({
|
|
437
|
-
keys,
|
|
438
|
-
type,
|
|
439
|
-
nonNullable
|
|
440
|
-
}) {
|
|
419
|
+
function createOmitDeclaration({ keys, type, nonNullable }) {
|
|
441
420
|
const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier("NonNullable"), [type]) : type;
|
|
442
421
|
if (Array.isArray(keys)) {
|
|
443
422
|
return factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [
|
|
@@ -478,5 +457,5 @@ var createTrue = factory.createTrue;
|
|
|
478
457
|
var createFalse = factory.createFalse;
|
|
479
458
|
|
|
480
459
|
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 };
|
|
481
|
-
//# sourceMappingURL=chunk-
|
|
482
|
-
//# sourceMappingURL=chunk-
|
|
460
|
+
//# sourceMappingURL=chunk-ZNZX6QZO.js.map
|
|
461
|
+
//# sourceMappingURL=chunk-ZNZX6QZO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/factory.ts"],"names":["modifiers","questionToken","node","propertyName"],"mappings":";;;;;;;;;;AAAA,IAAA,eAAA,GAAA;AAAA,QAAA,CAAA,eAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,UAAA,EAAA,MAAA,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EAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EACjE,MAAQ,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EACjE,OAAS,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,cAAc,CAAA;AAAA,EACnE,SAAW,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,gBAAgB,CAAA;AAAA,EACvE,IAAA,EAAM,QAAQ,qBAAsB,CAAA,OAAA,CAAQ,YAAY,EAAG,CAAA,UAAA,CAAW,WAAW,CAAC;AACpF;AAEO,IAAM,wBAAwB,OAAQ,CAAA;AAEtC,IAAM,0BAA0B,OAAQ,CAAA;AACxC,IAAM,uBAAuB,OAAQ,CAAA;AACrC,IAAM,sBAAsB,OAAQ,CAAA;AAEpC,IAAM,sBAAsB,OAAQ,CAAA;AAEpC,IAAM,wBAAwB,OAAQ,CAAA;AACtC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,mBAAmB,OAAQ,CAAA;AAEjC,IAAM,yBAAyB,OAAQ,CAAA;AACvC,IAAM,sBAAsB,OAAQ,CAAA;AACpC,IAAM,qBAAqB,OAAQ,CAAA;AACnC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,cAAc,OAAQ,CAAA","file":"chunk-ZNZX6QZO.js","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 = 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()) === value\n\n if (isExactNumber && isNumber(Number.parseInt(value.toString()))) {\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()))) {\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"]}
|
|
@@ -10,7 +10,7 @@ declare const syntaxKind: {
|
|
|
10
10
|
readonly union: 192;
|
|
11
11
|
};
|
|
12
12
|
declare function createQuestionToken(token?: boolean | ts.QuestionToken): ts.PunctuationToken<ts.SyntaxKind.QuestionToken> | undefined;
|
|
13
|
-
declare function createIntersectionDeclaration({ nodes, withParentheses
|
|
13
|
+
declare function createIntersectionDeclaration({ nodes, withParentheses }: {
|
|
14
14
|
nodes: Array<ts.TypeNode>;
|
|
15
15
|
withParentheses?: boolean;
|
|
16
16
|
}): ts.TypeNode | null;
|
|
@@ -18,18 +18,18 @@ declare function createIntersectionDeclaration({ nodes, withParentheses, }: {
|
|
|
18
18
|
* Minimum nodes length of 2
|
|
19
19
|
* @example `string & number`
|
|
20
20
|
*/
|
|
21
|
-
declare function createTupleDeclaration({ nodes, withParentheses
|
|
21
|
+
declare function createTupleDeclaration({ nodes, withParentheses }: {
|
|
22
22
|
nodes: Array<ts.TypeNode>;
|
|
23
23
|
withParentheses?: boolean;
|
|
24
24
|
}): ts.TypeNode | null;
|
|
25
|
-
declare function createArrayDeclaration({ nodes
|
|
25
|
+
declare function createArrayDeclaration({ nodes }: {
|
|
26
26
|
nodes: Array<ts.TypeNode>;
|
|
27
27
|
}): ts.TypeNode | null;
|
|
28
28
|
/**
|
|
29
29
|
* Minimum nodes length of 2
|
|
30
30
|
* @example `string | number`
|
|
31
31
|
*/
|
|
32
|
-
declare function createUnionDeclaration({ nodes, withParentheses
|
|
32
|
+
declare function createUnionDeclaration({ nodes, withParentheses }: {
|
|
33
33
|
nodes: Array<ts.TypeNode>;
|
|
34
34
|
withParentheses?: boolean;
|
|
35
35
|
}): ts.TypeNode;
|
|
@@ -54,7 +54,7 @@ declare function createJSDoc({ comments }: {
|
|
|
54
54
|
/**
|
|
55
55
|
* @link https://github.com/microsoft/TypeScript/issues/44151
|
|
56
56
|
*/
|
|
57
|
-
declare function appendJSDocToNode<TNode extends ts.Node>({ node, comments
|
|
57
|
+
declare function appendJSDocToNode<TNode extends ts.Node>({ node, comments }: {
|
|
58
58
|
node: TNode;
|
|
59
59
|
comments: Array<string | undefined>;
|
|
60
60
|
}): TNode;
|
|
@@ -83,7 +83,7 @@ declare function createTypeDeclaration({ syntax, isExportable, comments, name, t
|
|
|
83
83
|
name: string | ts.Identifier;
|
|
84
84
|
type: ts.TypeNode;
|
|
85
85
|
}): ts.TypeAliasDeclaration | ts.InterfaceDeclaration;
|
|
86
|
-
declare function createNamespaceDeclaration({ statements, name
|
|
86
|
+
declare function createNamespaceDeclaration({ statements, name }: {
|
|
87
87
|
name: string;
|
|
88
88
|
statements: ts.Statement[];
|
|
89
89
|
}): ts.ModuleDeclaration;
|
|
@@ -121,7 +121,7 @@ declare function createEnumDeclaration({ type, name, typeName, enums, }: {
|
|
|
121
121
|
typeName: string;
|
|
122
122
|
enums: [key: string | number, value: string | number | boolean][];
|
|
123
123
|
}): [name: ts.Node | undefined, type: ts.Node];
|
|
124
|
-
declare function createOmitDeclaration({ keys, type, nonNullable
|
|
124
|
+
declare function createOmitDeclaration({ keys, type, nonNullable }: {
|
|
125
125
|
keys: Array<string> | string;
|
|
126
126
|
type: ts.TypeNode;
|
|
127
127
|
nonNullable?: boolean;
|
|
@@ -10,7 +10,7 @@ declare const syntaxKind: {
|
|
|
10
10
|
readonly union: 192;
|
|
11
11
|
};
|
|
12
12
|
declare function createQuestionToken(token?: boolean | ts.QuestionToken): ts.PunctuationToken<ts.SyntaxKind.QuestionToken> | undefined;
|
|
13
|
-
declare function createIntersectionDeclaration({ nodes, withParentheses
|
|
13
|
+
declare function createIntersectionDeclaration({ nodes, withParentheses }: {
|
|
14
14
|
nodes: Array<ts.TypeNode>;
|
|
15
15
|
withParentheses?: boolean;
|
|
16
16
|
}): ts.TypeNode | null;
|
|
@@ -18,18 +18,18 @@ declare function createIntersectionDeclaration({ nodes, withParentheses, }: {
|
|
|
18
18
|
* Minimum nodes length of 2
|
|
19
19
|
* @example `string & number`
|
|
20
20
|
*/
|
|
21
|
-
declare function createTupleDeclaration({ nodes, withParentheses
|
|
21
|
+
declare function createTupleDeclaration({ nodes, withParentheses }: {
|
|
22
22
|
nodes: Array<ts.TypeNode>;
|
|
23
23
|
withParentheses?: boolean;
|
|
24
24
|
}): ts.TypeNode | null;
|
|
25
|
-
declare function createArrayDeclaration({ nodes
|
|
25
|
+
declare function createArrayDeclaration({ nodes }: {
|
|
26
26
|
nodes: Array<ts.TypeNode>;
|
|
27
27
|
}): ts.TypeNode | null;
|
|
28
28
|
/**
|
|
29
29
|
* Minimum nodes length of 2
|
|
30
30
|
* @example `string | number`
|
|
31
31
|
*/
|
|
32
|
-
declare function createUnionDeclaration({ nodes, withParentheses
|
|
32
|
+
declare function createUnionDeclaration({ nodes, withParentheses }: {
|
|
33
33
|
nodes: Array<ts.TypeNode>;
|
|
34
34
|
withParentheses?: boolean;
|
|
35
35
|
}): ts.TypeNode;
|
|
@@ -54,7 +54,7 @@ declare function createJSDoc({ comments }: {
|
|
|
54
54
|
/**
|
|
55
55
|
* @link https://github.com/microsoft/TypeScript/issues/44151
|
|
56
56
|
*/
|
|
57
|
-
declare function appendJSDocToNode<TNode extends ts.Node>({ node, comments
|
|
57
|
+
declare function appendJSDocToNode<TNode extends ts.Node>({ node, comments }: {
|
|
58
58
|
node: TNode;
|
|
59
59
|
comments: Array<string | undefined>;
|
|
60
60
|
}): TNode;
|
|
@@ -83,7 +83,7 @@ declare function createTypeDeclaration({ syntax, isExportable, comments, name, t
|
|
|
83
83
|
name: string | ts.Identifier;
|
|
84
84
|
type: ts.TypeNode;
|
|
85
85
|
}): ts.TypeAliasDeclaration | ts.InterfaceDeclaration;
|
|
86
|
-
declare function createNamespaceDeclaration({ statements, name
|
|
86
|
+
declare function createNamespaceDeclaration({ statements, name }: {
|
|
87
87
|
name: string;
|
|
88
88
|
statements: ts.Statement[];
|
|
89
89
|
}): ts.ModuleDeclaration;
|
|
@@ -121,7 +121,7 @@ declare function createEnumDeclaration({ type, name, typeName, enums, }: {
|
|
|
121
121
|
typeName: string;
|
|
122
122
|
enums: [key: string | number, value: string | number | boolean][];
|
|
123
123
|
}): [name: ts.Node | undefined, type: ts.Node];
|
|
124
|
-
declare function createOmitDeclaration({ keys, type, nonNullable
|
|
124
|
+
declare function createOmitDeclaration({ keys, type, nonNullable }: {
|
|
125
125
|
keys: Array<string> | string;
|
|
126
126
|
type: ts.TypeNode;
|
|
127
127
|
nonNullable?: boolean;
|
package/dist/factory.cjs
CHANGED
|
@@ -1,144 +1,144 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXEWLBD2X_cjs = require('./chunk-XEWLBD2X.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "appendJSDocToNode", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkXEWLBD2X_cjs.appendJSDocToNode; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "createArrayDeclaration", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkXEWLBD2X_cjs.createArrayDeclaration; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "createArrayTypeNode", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkXEWLBD2X_cjs.createArrayTypeNode; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "createEnumDeclaration", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkXEWLBD2X_cjs.createEnumDeclaration; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "createExportDeclaration", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkXEWLBD2X_cjs.createExportDeclaration; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "createFalse", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkXEWLBD2X_cjs.createFalse; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "createIdentifier", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkXEWLBD2X_cjs.createIdentifier; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "createImportDeclaration", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkXEWLBD2X_cjs.createImportDeclaration; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "createIndexSignature", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkXEWLBD2X_cjs.createIndexSignature; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "createInterfaceDeclaration", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkXEWLBD2X_cjs.createInterfaceDeclaration; }
|
|
46
46
|
});
|
|
47
47
|
Object.defineProperty(exports, "createIntersectionDeclaration", {
|
|
48
48
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkXEWLBD2X_cjs.createIntersectionDeclaration; }
|
|
50
50
|
});
|
|
51
51
|
Object.defineProperty(exports, "createJSDoc", {
|
|
52
52
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkXEWLBD2X_cjs.createJSDoc; }
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(exports, "createLiteralTypeNode", {
|
|
56
56
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkXEWLBD2X_cjs.createLiteralTypeNode; }
|
|
58
58
|
});
|
|
59
59
|
Object.defineProperty(exports, "createNamespaceDeclaration", {
|
|
60
60
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
61
|
+
get: function () { return chunkXEWLBD2X_cjs.createNamespaceDeclaration; }
|
|
62
62
|
});
|
|
63
63
|
Object.defineProperty(exports, "createNull", {
|
|
64
64
|
enumerable: true,
|
|
65
|
-
get: function () { return
|
|
65
|
+
get: function () { return chunkXEWLBD2X_cjs.createNull; }
|
|
66
66
|
});
|
|
67
67
|
Object.defineProperty(exports, "createNumericLiteral", {
|
|
68
68
|
enumerable: true,
|
|
69
|
-
get: function () { return
|
|
69
|
+
get: function () { return chunkXEWLBD2X_cjs.createNumericLiteral; }
|
|
70
70
|
});
|
|
71
71
|
Object.defineProperty(exports, "createOmitDeclaration", {
|
|
72
72
|
enumerable: true,
|
|
73
|
-
get: function () { return
|
|
73
|
+
get: function () { return chunkXEWLBD2X_cjs.createOmitDeclaration; }
|
|
74
74
|
});
|
|
75
75
|
Object.defineProperty(exports, "createOptionalTypeNode", {
|
|
76
76
|
enumerable: true,
|
|
77
|
-
get: function () { return
|
|
77
|
+
get: function () { return chunkXEWLBD2X_cjs.createOptionalTypeNode; }
|
|
78
78
|
});
|
|
79
79
|
Object.defineProperty(exports, "createParameterSignature", {
|
|
80
80
|
enumerable: true,
|
|
81
|
-
get: function () { return
|
|
81
|
+
get: function () { return chunkXEWLBD2X_cjs.createParameterSignature; }
|
|
82
82
|
});
|
|
83
83
|
Object.defineProperty(exports, "createPropertySignature", {
|
|
84
84
|
enumerable: true,
|
|
85
|
-
get: function () { return
|
|
85
|
+
get: function () { return chunkXEWLBD2X_cjs.createPropertySignature; }
|
|
86
86
|
});
|
|
87
87
|
Object.defineProperty(exports, "createQuestionToken", {
|
|
88
88
|
enumerable: true,
|
|
89
|
-
get: function () { return
|
|
89
|
+
get: function () { return chunkXEWLBD2X_cjs.createQuestionToken; }
|
|
90
90
|
});
|
|
91
91
|
Object.defineProperty(exports, "createRestTypeNode", {
|
|
92
92
|
enumerable: true,
|
|
93
|
-
get: function () { return
|
|
93
|
+
get: function () { return chunkXEWLBD2X_cjs.createRestTypeNode; }
|
|
94
94
|
});
|
|
95
95
|
Object.defineProperty(exports, "createStringLiteral", {
|
|
96
96
|
enumerable: true,
|
|
97
|
-
get: function () { return
|
|
97
|
+
get: function () { return chunkXEWLBD2X_cjs.createStringLiteral; }
|
|
98
98
|
});
|
|
99
99
|
Object.defineProperty(exports, "createTrue", {
|
|
100
100
|
enumerable: true,
|
|
101
|
-
get: function () { return
|
|
101
|
+
get: function () { return chunkXEWLBD2X_cjs.createTrue; }
|
|
102
102
|
});
|
|
103
103
|
Object.defineProperty(exports, "createTupleDeclaration", {
|
|
104
104
|
enumerable: true,
|
|
105
|
-
get: function () { return
|
|
105
|
+
get: function () { return chunkXEWLBD2X_cjs.createTupleDeclaration; }
|
|
106
106
|
});
|
|
107
107
|
Object.defineProperty(exports, "createTupleTypeNode", {
|
|
108
108
|
enumerable: true,
|
|
109
|
-
get: function () { return
|
|
109
|
+
get: function () { return chunkXEWLBD2X_cjs.createTupleTypeNode; }
|
|
110
110
|
});
|
|
111
111
|
Object.defineProperty(exports, "createTypeAliasDeclaration", {
|
|
112
112
|
enumerable: true,
|
|
113
|
-
get: function () { return
|
|
113
|
+
get: function () { return chunkXEWLBD2X_cjs.createTypeAliasDeclaration; }
|
|
114
114
|
});
|
|
115
115
|
Object.defineProperty(exports, "createTypeDeclaration", {
|
|
116
116
|
enumerable: true,
|
|
117
|
-
get: function () { return
|
|
117
|
+
get: function () { return chunkXEWLBD2X_cjs.createTypeDeclaration; }
|
|
118
118
|
});
|
|
119
119
|
Object.defineProperty(exports, "createTypeLiteralNode", {
|
|
120
120
|
enumerable: true,
|
|
121
|
-
get: function () { return
|
|
121
|
+
get: function () { return chunkXEWLBD2X_cjs.createTypeLiteralNode; }
|
|
122
122
|
});
|
|
123
123
|
Object.defineProperty(exports, "createTypeReferenceNode", {
|
|
124
124
|
enumerable: true,
|
|
125
|
-
get: function () { return
|
|
125
|
+
get: function () { return chunkXEWLBD2X_cjs.createTypeReferenceNode; }
|
|
126
126
|
});
|
|
127
127
|
Object.defineProperty(exports, "createUnionDeclaration", {
|
|
128
128
|
enumerable: true,
|
|
129
|
-
get: function () { return
|
|
129
|
+
get: function () { return chunkXEWLBD2X_cjs.createUnionDeclaration; }
|
|
130
130
|
});
|
|
131
131
|
Object.defineProperty(exports, "keywordTypeNodes", {
|
|
132
132
|
enumerable: true,
|
|
133
|
-
get: function () { return
|
|
133
|
+
get: function () { return chunkXEWLBD2X_cjs.keywordTypeNodes; }
|
|
134
134
|
});
|
|
135
135
|
Object.defineProperty(exports, "modifiers", {
|
|
136
136
|
enumerable: true,
|
|
137
|
-
get: function () { return
|
|
137
|
+
get: function () { return chunkXEWLBD2X_cjs.modifiers; }
|
|
138
138
|
});
|
|
139
139
|
Object.defineProperty(exports, "syntaxKind", {
|
|
140
140
|
enumerable: true,
|
|
141
|
-
get: function () { return
|
|
141
|
+
get: function () { return chunkXEWLBD2X_cjs.syntaxKind; }
|
|
142
142
|
});
|
|
143
143
|
//# sourceMappingURL=factory.cjs.map
|
|
144
144
|
//# sourceMappingURL=factory.cjs.map
|
package/dist/factory.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'typescript';
|
|
2
|
-
export { j as appendJSDocToNode, d as createArrayDeclaration, A as createArrayTypeNode, t as createEnumDeclaration, r as createExportDeclaration, I as createFalse, D as createIdentifier, q as createImportDeclaration, k as createIndexSignature, n as createInterfaceDeclaration, a as createIntersectionDeclaration, i as createJSDoc, B as createLiteralTypeNode, p as createNamespaceDeclaration, C as createNull, y as createNumericLiteral, u as createOmitDeclaration, E as createOptionalTypeNode, h as createParameterSignature, g as createPropertySignature, c as createQuestionToken, G as createRestTypeNode, z as createStringLiteral, H as createTrue, b as createTupleDeclaration, F as createTupleTypeNode, l as createTypeAliasDeclaration, o as createTypeDeclaration, w as createTypeLiteralNode, x as createTypeReferenceNode, e as createUnionDeclaration, v as keywordTypeNodes, m as modifiers, s as syntaxKind } from './factory-
|
|
2
|
+
export { j as appendJSDocToNode, d as createArrayDeclaration, A as createArrayTypeNode, t as createEnumDeclaration, r as createExportDeclaration, I as createFalse, D as createIdentifier, q as createImportDeclaration, k as createIndexSignature, n as createInterfaceDeclaration, a as createIntersectionDeclaration, i as createJSDoc, B as createLiteralTypeNode, p as createNamespaceDeclaration, C as createNull, y as createNumericLiteral, u as createOmitDeclaration, E as createOptionalTypeNode, h as createParameterSignature, g as createPropertySignature, c as createQuestionToken, G as createRestTypeNode, z as createStringLiteral, H as createTrue, b as createTupleDeclaration, F as createTupleTypeNode, l as createTypeAliasDeclaration, o as createTypeDeclaration, w as createTypeLiteralNode, x as createTypeReferenceNode, e as createUnionDeclaration, v as keywordTypeNodes, m as modifiers, s as syntaxKind } from './factory-Cn6Avpxk.cjs';
|
package/dist/factory.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'typescript';
|
|
2
|
-
export { j as appendJSDocToNode, d as createArrayDeclaration, A as createArrayTypeNode, t as createEnumDeclaration, r as createExportDeclaration, I as createFalse, D as createIdentifier, q as createImportDeclaration, k as createIndexSignature, n as createInterfaceDeclaration, a as createIntersectionDeclaration, i as createJSDoc, B as createLiteralTypeNode, p as createNamespaceDeclaration, C as createNull, y as createNumericLiteral, u as createOmitDeclaration, E as createOptionalTypeNode, h as createParameterSignature, g as createPropertySignature, c as createQuestionToken, G as createRestTypeNode, z as createStringLiteral, H as createTrue, b as createTupleDeclaration, F as createTupleTypeNode, l as createTypeAliasDeclaration, o as createTypeDeclaration, w as createTypeLiteralNode, x as createTypeReferenceNode, e as createUnionDeclaration, v as keywordTypeNodes, m as modifiers, s as syntaxKind } from './factory-
|
|
2
|
+
export { j as appendJSDocToNode, d as createArrayDeclaration, A as createArrayTypeNode, t as createEnumDeclaration, r as createExportDeclaration, I as createFalse, D as createIdentifier, q as createImportDeclaration, k as createIndexSignature, n as createInterfaceDeclaration, a as createIntersectionDeclaration, i as createJSDoc, B as createLiteralTypeNode, p as createNamespaceDeclaration, C as createNull, y as createNumericLiteral, u as createOmitDeclaration, E as createOptionalTypeNode, h as createParameterSignature, g as createPropertySignature, c as createQuestionToken, G as createRestTypeNode, z as createStringLiteral, H as createTrue, b as createTupleDeclaration, F as createTupleTypeNode, l as createTypeAliasDeclaration, o as createTypeDeclaration, w as createTypeLiteralNode, x as createTypeReferenceNode, e as createUnionDeclaration, v as keywordTypeNodes, m as modifiers, s as syntaxKind } from './factory-Cn6Avpxk.js';
|
package/dist/factory.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
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 } from './chunk-
|
|
1
|
+
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 } from './chunk-ZNZX6QZO.js';
|
|
2
2
|
//# sourceMappingURL=factory.js.map
|
|
3
3
|
//# sourceMappingURL=factory.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXEWLBD2X_cjs = require('./chunk-XEWLBD2X.cjs');
|
|
4
4
|
var ts = require('typescript');
|
|
5
5
|
var prettier = require('prettier');
|
|
6
6
|
var pluginTypescript = require('prettier/plugins/typescript');
|
|
@@ -53,7 +53,7 @@ async function format(source) {
|
|
|
53
53
|
|
|
54
54
|
Object.defineProperty(exports, "factory", {
|
|
55
55
|
enumerable: true,
|
|
56
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunkXEWLBD2X_cjs.factory_exports; }
|
|
57
57
|
});
|
|
58
58
|
exports.format = format;
|
|
59
59
|
exports.print = print;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { factory_exports as factory } from './chunk-
|
|
1
|
+
export { factory_exports as factory } from './chunk-ZNZX6QZO.js';
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import { format as format$1 } from 'prettier';
|
|
4
4
|
import pluginTypescript from 'prettier/plugins/typescript';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/parser-ts",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.10",
|
|
4
4
|
"description": "TypeScript parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"tsup": "^8.4.0",
|
|
57
|
-
"@kubb/config-ts": "3.10.
|
|
58
|
-
"@kubb/config-tsup": "3.10.
|
|
57
|
+
"@kubb/config-ts": "3.10.10",
|
|
58
|
+
"@kubb/config-tsup": "3.10.10"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=20"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"build": "tsup",
|
|
69
69
|
"clean": "npx rimraf ./dist",
|
|
70
70
|
"lint": "bun biome lint .",
|
|
71
|
-
"lint:fix": "bun biome lint --
|
|
71
|
+
"lint:fix": "bun biome lint--fix --unsafe .",
|
|
72
72
|
"release": "pnpm publish --no-git-check",
|
|
73
73
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
74
74
|
"start": "tsup --watch",
|
package/src/factory.ts
CHANGED
|
@@ -44,13 +44,7 @@ export function createQuestionToken(token?: boolean | ts.QuestionToken) {
|
|
|
44
44
|
return token
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export function createIntersectionDeclaration({
|
|
48
|
-
nodes,
|
|
49
|
-
withParentheses,
|
|
50
|
-
}: {
|
|
51
|
-
nodes: Array<ts.TypeNode>
|
|
52
|
-
withParentheses?: boolean
|
|
53
|
-
}): ts.TypeNode | null {
|
|
47
|
+
export function createIntersectionDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode | null {
|
|
54
48
|
if (!nodes.length) {
|
|
55
49
|
return null
|
|
56
50
|
}
|
|
@@ -72,13 +66,7 @@ export function createIntersectionDeclaration({
|
|
|
72
66
|
* Minimum nodes length of 2
|
|
73
67
|
* @example `string & number`
|
|
74
68
|
*/
|
|
75
|
-
export function createTupleDeclaration({
|
|
76
|
-
nodes,
|
|
77
|
-
withParentheses,
|
|
78
|
-
}: {
|
|
79
|
-
nodes: Array<ts.TypeNode>
|
|
80
|
-
withParentheses?: boolean
|
|
81
|
-
}): ts.TypeNode | null {
|
|
69
|
+
export function createTupleDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode | null {
|
|
82
70
|
if (!nodes.length) {
|
|
83
71
|
return null
|
|
84
72
|
}
|
|
@@ -96,11 +84,7 @@ export function createTupleDeclaration({
|
|
|
96
84
|
return node
|
|
97
85
|
}
|
|
98
86
|
|
|
99
|
-
export function createArrayDeclaration({
|
|
100
|
-
nodes,
|
|
101
|
-
}: {
|
|
102
|
-
nodes: Array<ts.TypeNode>
|
|
103
|
-
}): ts.TypeNode | null {
|
|
87
|
+
export function createArrayDeclaration({ nodes }: { nodes: Array<ts.TypeNode> }): ts.TypeNode | null {
|
|
104
88
|
if (!nodes.length) {
|
|
105
89
|
return factory.createTupleTypeNode([])
|
|
106
90
|
}
|
|
@@ -116,13 +100,7 @@ export function createArrayDeclaration({
|
|
|
116
100
|
* Minimum nodes length of 2
|
|
117
101
|
* @example `string | number`
|
|
118
102
|
*/
|
|
119
|
-
export function createUnionDeclaration({
|
|
120
|
-
nodes,
|
|
121
|
-
withParentheses,
|
|
122
|
-
}: {
|
|
123
|
-
nodes: Array<ts.TypeNode>
|
|
124
|
-
withParentheses?: boolean
|
|
125
|
-
}): ts.TypeNode {
|
|
103
|
+
export function createUnionDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode {
|
|
126
104
|
if (!nodes.length) {
|
|
127
105
|
return keywordTypeNodes.any
|
|
128
106
|
}
|
|
@@ -201,13 +179,7 @@ export function createJSDoc({ comments }: { comments: string[] }) {
|
|
|
201
179
|
/**
|
|
202
180
|
* @link https://github.com/microsoft/TypeScript/issues/44151
|
|
203
181
|
*/
|
|
204
|
-
export function appendJSDocToNode<TNode extends ts.Node>({
|
|
205
|
-
node,
|
|
206
|
-
comments,
|
|
207
|
-
}: {
|
|
208
|
-
node: TNode
|
|
209
|
-
comments: Array<string | undefined>
|
|
210
|
-
}) {
|
|
182
|
+
export function appendJSDocToNode<TNode extends ts.Node>({ node, comments }: { node: TNode; comments: Array<string | undefined> }) {
|
|
211
183
|
const filteredComments = comments.filter(Boolean)
|
|
212
184
|
|
|
213
185
|
if (!filteredComments.length) {
|
|
@@ -306,13 +278,7 @@ export function createTypeDeclaration({
|
|
|
306
278
|
})
|
|
307
279
|
}
|
|
308
280
|
|
|
309
|
-
export function createNamespaceDeclaration({
|
|
310
|
-
statements,
|
|
311
|
-
name,
|
|
312
|
-
}: {
|
|
313
|
-
name: string
|
|
314
|
-
statements: ts.Statement[]
|
|
315
|
-
}) {
|
|
281
|
+
export function createNamespaceDeclaration({ statements, name }: { name: string; statements: ts.Statement[] }) {
|
|
316
282
|
return factory.createModuleDeclaration(
|
|
317
283
|
[factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
|
318
284
|
factory.createIdentifier(name),
|
|
@@ -563,15 +529,7 @@ export function createEnumDeclaration({
|
|
|
563
529
|
]
|
|
564
530
|
}
|
|
565
531
|
|
|
566
|
-
export function createOmitDeclaration({
|
|
567
|
-
keys,
|
|
568
|
-
type,
|
|
569
|
-
nonNullable,
|
|
570
|
-
}: {
|
|
571
|
-
keys: Array<string> | string
|
|
572
|
-
type: ts.TypeNode
|
|
573
|
-
nonNullable?: boolean
|
|
574
|
-
}) {
|
|
532
|
+
export function createOmitDeclaration({ keys, type, nonNullable }: { keys: Array<string> | string; type: ts.TypeNode; nonNullable?: boolean }) {
|
|
575
533
|
const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier('NonNullable'), [type]) : type
|
|
576
534
|
|
|
577
535
|
if (Array.isArray(keys)) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factory.ts"],"names":["ts","modifiers","questionToken","node","propertyName","isNumber"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA,eAAA,GAAA;AAAA,QAAA,CAAA,eAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,gBAAA,EAAA,M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,aAAa,OAAQ,CAAA;AAC3B,IAAM,cAAc,OAAQ,CAAA","file":"chunk-3H6MBFVZ.cjs","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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n}: {\n nodes: Array<ts.TypeNode>\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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>({\n node,\n comments,\n}: {\n node: TNode\n comments: Array<string | undefined>\n}) {\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({\n statements,\n name,\n}: {\n name: string\n statements: ts.Statement[]\n}) {\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 = 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()) === value\n\n if (isExactNumber && isNumber(Number.parseInt(value.toString()))) {\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()))) {\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({\n keys,\n type,\n nonNullable,\n}: {\n keys: Array<string> | string\n type: ts.TypeNode\n nonNullable?: boolean\n}) {\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factory.ts"],"names":["modifiers","questionToken","node","propertyName"],"mappings":";;;;;;;;;;AAAA,IAAA,eAAA,GAAA;AAAA,QAAA,CAAA,eAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,qBAAA,EAAA,MA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CAAA;AAAA,EACjE,OAAS,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EAClE,MAAQ,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EACjE,MAAQ,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EACjE,OAAS,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,cAAc,CAAA;AAAA,EACnE,SAAW,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,gBAAgB,CAAA;AAAA,EACvE,IAAA,EAAM,QAAQ,qBAAsB,CAAA,OAAA,CAAQ,YAAY,EAAG,CAAA,UAAA,CAAW,WAAW,CAAC;AACpF;AAEO,IAAM,wBAAwB,OAAQ,CAAA;AAEtC,IAAM,0BAA0B,OAAQ,CAAA;AACxC,IAAM,uBAAuB,OAAQ,CAAA;AACrC,IAAM,sBAAsB,OAAQ,CAAA;AAEpC,IAAM,sBAAsB,OAAQ,CAAA;AAEpC,IAAM,wBAAwB,OAAQ,CAAA;AACtC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,mBAAmB,OAAQ,CAAA;AAEjC,IAAM,yBAAyB,OAAQ,CAAA;AACvC,IAAM,sBAAsB,OAAQ,CAAA;AACpC,IAAM,qBAAqB,OAAQ,CAAA;AACnC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,cAAc,OAAQ,CAAA","file":"chunk-7QFNR36N.js","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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n}: {\n nodes: Array<ts.TypeNode>\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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>({\n node,\n comments,\n}: {\n node: TNode\n comments: Array<string | undefined>\n}) {\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({\n statements,\n name,\n}: {\n name: string\n statements: ts.Statement[]\n}) {\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 = 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()) === value\n\n if (isExactNumber && isNumber(Number.parseInt(value.toString()))) {\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()))) {\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({\n keys,\n type,\n nonNullable,\n}: {\n keys: Array<string> | string\n type: ts.TypeNode\n nonNullable?: boolean\n}) {\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"]}
|