@kubb/ts-codegen
Advanced tools
Comparing version 1.7.0-canary.20230903T185725 to 1.7.0-canary.20230905T174910
@@ -15,5 +15,6 @@ import ts from 'typescript'; | ||
declare function createQuestionToken(token?: boolean | ts.QuestionToken): ts.PunctuationToken<ts.SyntaxKind.QuestionToken> | undefined; | ||
declare function createIntersectionDeclaration({ nodes }: { | ||
declare function createIntersectionDeclaration({ nodes, withParentheses, }: { | ||
nodes: ArrayTwoOrMore<ts.TypeNode>; | ||
}): ts.IntersectionTypeNode; | ||
withParentheses?: boolean; | ||
}): ts.TypeNode | null; | ||
/** | ||
@@ -24,5 +25,6 @@ * | ||
*/ | ||
declare function createTupleDeclaration({ nodes }: { | ||
declare function createTupleDeclaration({ nodes, withParentheses }: { | ||
nodes: ArrayTwoOrMore<ts.TypeNode>; | ||
}): ts.TupleTypeNode; | ||
withParentheses?: boolean; | ||
}): ts.TypeNode | null; | ||
/** | ||
@@ -33,5 +35,6 @@ * | ||
*/ | ||
declare function createUnionDeclaration({ nodes }: { | ||
declare function createUnionDeclaration({ nodes, withParentheses }: { | ||
nodes: ArrayTwoOrMore<ts.TypeNode>; | ||
}): ts.UnionTypeNode; | ||
withParentheses?: boolean; | ||
}): ts.TypeNode | null; | ||
declare function createPropertySignature({ modifiers, name, questionToken, type, }: { | ||
@@ -108,4 +111,4 @@ modifiers?: Array<ts.Modifier>; | ||
declare function print(elements: ts.Node | Array<ts.Node | undefined>, fileName?: string): string; | ||
declare function print(elements: ts.Node | Array<ts.Node | undefined> | null, fileName?: string): string; | ||
export { ArrayTwoOrMore, appendJSDocToNode, createEnumDeclaration, createExportDeclaration, createImportDeclaration, createIndexSignature, createIntersectionDeclaration, createJSDoc, createParameterSignature, createPropertySignature, createQuestionToken, createTupleDeclaration, createTypeAliasDeclaration, createUnionDeclaration, modifiers, print }; |
@@ -35,10 +35,43 @@ import { createRequire } from 'module'; | ||
} | ||
function createIntersectionDeclaration({ nodes }) { | ||
return factory.createIntersectionTypeNode(nodes); | ||
function createIntersectionDeclaration({ | ||
nodes, | ||
withParentheses | ||
}) { | ||
if (!nodes.length) { | ||
return null; | ||
} | ||
if (nodes.length === 1) { | ||
return nodes[0]; | ||
} | ||
const node = factory.createIntersectionTypeNode(nodes); | ||
if (withParentheses) { | ||
return factory.createParenthesizedType(node); | ||
} | ||
return node; | ||
} | ||
function createTupleDeclaration({ nodes }) { | ||
return factory.createTupleTypeNode(nodes); | ||
function createTupleDeclaration({ nodes, withParentheses }) { | ||
if (!nodes.length) { | ||
return null; | ||
} | ||
if (nodes.length === 1) { | ||
return nodes[0]; | ||
} | ||
const node = factory.createTupleTypeNode(nodes); | ||
if (withParentheses) { | ||
return factory.createParenthesizedType(node); | ||
} | ||
return node; | ||
} | ||
function createUnionDeclaration({ nodes }) { | ||
return factory.createUnionTypeNode(nodes); | ||
function createUnionDeclaration({ nodes, withParentheses }) { | ||
if (!nodes.length) { | ||
return null; | ||
} | ||
if (nodes.length === 1) { | ||
return nodes[0]; | ||
} | ||
const node = factory.createUnionTypeNode(nodes); | ||
if (withParentheses) { | ||
return factory.createParenthesizedType(node); | ||
} | ||
return node; | ||
} | ||
@@ -237,2 +270,5 @@ function createPropertySignature({ | ||
let nodes = []; | ||
if (!elements) { | ||
return ""; | ||
} | ||
if (Array.isArray(elements)) { | ||
@@ -239,0 +275,0 @@ nodes = elements; |
{ | ||
"name": "@kubb/ts-codegen", | ||
"version": "1.7.0-canary.20230903T185725", | ||
"version": "1.7.0-canary.20230905T174910", | ||
"description": "Generator ts-codegen", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
68889
690