@kubb/parser
Advanced tools
Comparing version 2.0.0-canary.20231030T124932 to 2.0.0
@@ -67,2 +67,6 @@ import ts from 'typescript'; | ||
}): ts.TypeAliasDeclaration; | ||
declare function createNamespaceDeclaration({ statements, name, }: { | ||
name: string; | ||
statements: ts.Statement[]; | ||
}): ts.ModuleDeclaration; | ||
/** | ||
@@ -72,4 +76,4 @@ * In { propertyName: string; name?: string } is `name` being used to make the type more unique when multiple same names are used. | ||
*/ | ||
declare function createImportDeclaration({ name, path, isTypeOnly, }: { | ||
name: string | Array<ts.Identifier | string | { | ||
declare function createImportDeclaration({ name, path, isTypeOnly, isNameSpace, }: { | ||
name: string | Array<string | { | ||
propertyName: string; | ||
@@ -80,2 +84,3 @@ name?: string; | ||
isTypeOnly?: boolean; | ||
isNameSpace?: boolean; | ||
}): ts.ImportDeclaration; | ||
@@ -127,2 +132,2 @@ declare function createExportDeclaration({ path, asAlias, isTypeOnly, name, }: { | ||
export { appendJSDocToNode, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createIdentifier, createImportDeclaration, createIndexSignature, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNull, createNumericLiteral, createOmitDeclaration, createParameterSignature, createPropertySignature, createQuestionToken, createStringLiteral, createTupleDeclaration, createTypeAliasDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers }; | ||
export { appendJSDocToNode, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createIdentifier, createImportDeclaration, createIndexSignature, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createParameterSignature, createPropertySignature, createQuestionToken, createStringLiteral, createTupleDeclaration, createTypeAliasDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers }; |
@@ -140,11 +140,29 @@ import { createRequire } from 'module'; | ||
} | ||
function createNamespaceDeclaration({ | ||
statements, | ||
name | ||
}) { | ||
return factory.createModuleDeclaration( | ||
[factory.createToken(ts.SyntaxKind.ExportKeyword)], | ||
factory.createIdentifier(name), | ||
factory.createModuleBlock(statements), | ||
ts.NodeFlags.Namespace | ||
); | ||
} | ||
function createImportDeclaration({ | ||
name, | ||
path, | ||
isTypeOnly = false | ||
isTypeOnly = false, | ||
isNameSpace = false | ||
}) { | ||
if (!Array.isArray(name)) { | ||
let importPropertyName = factory.createIdentifier(name); | ||
let importName = void 0; | ||
if (isNameSpace) { | ||
importPropertyName = void 0; | ||
importName = factory.createNamespaceImport(factory.createIdentifier(name)); | ||
} | ||
return factory.createImportDeclaration( | ||
void 0, | ||
factory.createImportClause(isTypeOnly, factory.createIdentifier(name), void 0), | ||
factory.createImportClause(isTypeOnly, importPropertyName, importName), | ||
factory.createStringLiteral(path), | ||
@@ -160,5 +178,5 @@ void 0 | ||
factory.createNamedImports( | ||
name.map((propertyName2) => { | ||
if (typeof propertyName2 === "object") { | ||
const obj = propertyName2; | ||
name.map((item) => { | ||
if (typeof item === "object") { | ||
const obj = item; | ||
if (obj.name) { | ||
@@ -169,3 +187,3 @@ return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name)); | ||
} | ||
return factory.createImportSpecifier(false, void 0, typeof propertyName2 === "string" ? factory.createIdentifier(propertyName2) : propertyName2); | ||
return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item)); | ||
}) | ||
@@ -311,4 +329,4 @@ ) | ||
export { appendJSDocToNode, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createIdentifier, createImportDeclaration, createIndexSignature, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNull, createNumericLiteral, createOmitDeclaration, createParameterSignature, createPropertySignature, createQuestionToken, createStringLiteral, createTupleDeclaration, createTypeAliasDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers }; | ||
export { appendJSDocToNode, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createIdentifier, createImportDeclaration, createIndexSignature, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createParameterSignature, createPropertySignature, createQuestionToken, createStringLiteral, createTupleDeclaration, createTypeAliasDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=factory.js.map |
import ts, { PrinterOptions } from 'typescript'; | ||
export { default as ts } from 'typescript'; | ||
@@ -3,0 +4,0 @@ type ParseResult = { |
@@ -6,5 +6,7 @@ import { createRequire } from 'module'; | ||
var { factory } = ts; | ||
function print(elements, { source = "", baseName = "print.ts", removeComments, noEmitHelpers, newLine } = {}) { | ||
const printer = ts.createPrinter({ omitTrailingSemicolon: false, newLine: newLine || ts.NewLineKind.LineFeed, removeComments, noEmitHelpers }); | ||
const sourceFile = ts.createSourceFile(baseName, source, ts.ScriptTarget.ESNext, true, ts.ScriptKind.TS); | ||
var escapeNewLines = (code) => code.replace(/\n\n/g, "\n/* :newline: */"); | ||
var restoreNewLines = (code) => code.replace(/\/\* :newline: \*\//g, "\n"); | ||
function print(elements, { source = "", baseName = "print.ts", removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed } = {}) { | ||
const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, false, ts.ScriptKind.TS); | ||
const printer = ts.createPrinter({ omitTrailingSemicolon: true, newLine, removeComments, noEmitHelpers }); | ||
let nodes = []; | ||
@@ -21,3 +23,3 @@ if (!elements) { | ||
const outputSource = printer.printFile(sourceFile); | ||
return [outputFile, outputSource].filter(Boolean).join("\n"); | ||
return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join("\n"); | ||
} | ||
@@ -24,0 +26,0 @@ |
{ | ||
"name": "@kubb/parser", | ||
"version": "2.0.0-canary.20231030T124932", | ||
"version": "2.0.0", | ||
"description": "Generator parser", | ||
@@ -38,2 +38,3 @@ "keywords": [ | ||
"files": [ | ||
"src", | ||
"dist", | ||
@@ -44,10 +45,10 @@ "!/**/**.test.**", | ||
"dependencies": { | ||
"typescript": "^5.2.2" | ||
"typescript": "^5.3.3" | ||
}, | ||
"devDependencies": { | ||
"@kubb/eslint-config": "canary", | ||
"@kubb/ts-config": "canary", | ||
"@kubb/tsup-config": "canary", | ||
"eslint": "^8.52.0", | ||
"tsup": "^7.2.0" | ||
"eslint": "^8.55.0", | ||
"tsup": "^8.0.1", | ||
"@kubb/eslint-config": "1.1.8", | ||
"@kubb/ts-config": "0.1.0", | ||
"@kubb/tsup-config": "1.1.8" | ||
}, | ||
@@ -69,4 +70,3 @@ "packageManager": "pnpm@8.3.0", | ||
"release": "pnpm publish --no-git-check", | ||
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check -tag canary", | ||
"release:alpha": "bash ../../.github/canary.sh && node ../../scripts/build.js alpha && pnpm publish --no-git-check -tag alpha", | ||
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check", | ||
"start": "tsup --watch", | ||
@@ -73,0 +73,0 @@ "test": "vitest --passWithNoTests", |
@@ -21,3 +21,3 @@ <div align="center"> | ||
<h4> | ||
<a href="https://codesandbox.io/s/github/kubb-project/kubb/tree/main/examples/typescript" target="_blank">View Demo</a> | ||
<a href="https://codesandbox.io/s/github/kubb-project/kubb/tree/alpha/examples/typescript" target="_blank">View Demo</a> | ||
<span> · </span> | ||
@@ -24,0 +24,0 @@ <a href="https://kubb.dev/" target="_blank">Documentation</a> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
108704
19
1335
1
Updatedtypescript@^5.3.3