@kubb/parser
Advanced tools
Comparing version 2.0.0-beta.6 to 2.0.0-beta.7
@@ -75,4 +75,4 @@ import ts from 'typescript'; | ||
*/ | ||
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; | ||
@@ -83,2 +83,3 @@ name?: string; | ||
isTypeOnly?: boolean; | ||
isNameSpace?: boolean; | ||
}): ts.ImportDeclaration; | ||
@@ -85,0 +86,0 @@ declare function createExportDeclaration({ path, asAlias, isTypeOnly, name, }: { |
@@ -154,8 +154,15 @@ import { createRequire } from 'module'; | ||
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), | ||
@@ -171,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) { | ||
@@ -180,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)); | ||
}) | ||
@@ -183,0 +190,0 @@ ) |
{ | ||
"name": "@kubb/parser", | ||
"version": "2.0.0-beta.6", | ||
"version": "2.0.0-beta.7", | ||
"description": "Generator parser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -237,11 +237,21 @@ /* eslint-disable @typescript-eslint/unbound-method */ | ||
isTypeOnly = false, | ||
isNameSpace = false, | ||
}: { | ||
name: string | Array<ts.Identifier | string | { propertyName: string; name?: string }> | ||
name: string | Array<string | { propertyName: string; name?: string }> | ||
path: string | ||
isTypeOnly?: boolean | ||
isNameSpace?: boolean | ||
}) { | ||
if (!Array.isArray(name)) { | ||
let importPropertyName: ts.Identifier | undefined = factory.createIdentifier(name) | ||
let importName: ts.NamedImportBindings | undefined = undefined | ||
if (isNameSpace) { | ||
importPropertyName = undefined | ||
importName = factory.createNamespaceImport(factory.createIdentifier(name)) | ||
} | ||
return factory.createImportDeclaration( | ||
undefined, | ||
factory.createImportClause(isTypeOnly, factory.createIdentifier(name), undefined), | ||
factory.createImportClause(isTypeOnly, importPropertyName, importName), | ||
factory.createStringLiteral(path), | ||
@@ -258,12 +268,13 @@ undefined, | ||
factory.createNamedImports( | ||
name.map((propertyName) => { | ||
if (typeof propertyName === 'object') { | ||
const obj = propertyName as { propertyName: string; name?: string } | ||
name.map((item) => { | ||
if (typeof item === 'object') { | ||
const obj = item as { propertyName: string; name?: string } | ||
if (obj.name) { | ||
return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name)) | ||
} | ||
return factory.createImportSpecifier(false, undefined, factory.createIdentifier(obj.propertyName)) | ||
} | ||
return factory.createImportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName) | ||
return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item)) | ||
}), | ||
@@ -270,0 +281,0 @@ ), |
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
108711
1335