From 48d45c298525144ba4d78e0283e9c07e7d248c27 Mon Sep 17 00:00:00 2001 From: Max Holman Date: Sat, 20 Jul 2024 11:39:17 +0800 Subject: [PATCH] fix: avoid adding empty type only imports --- lib/process-document.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/process-document.ts b/lib/process-document.ts index d9791d6..559feac 100644 --- a/lib/process-document.ts +++ b/lib/process-document.ts @@ -626,9 +626,12 @@ export async function processOpenApiDocument( ], }); + const namedImports = [...new Set([...inputTypes, ...outputTypes])]; + + if (namedImports.length > 0) { mainFile.addImportDeclaration({ moduleSpecifier: typesModuleSpecifier, - namedImports: [...new Set([...inputTypes, ...outputTypes])] + namedImports: namedImports .filter((t: T | 'void'): t is T => t !== 'void') .map((t) => ({ name: t.getName(), @@ -636,6 +639,7 @@ export async function processOpenApiDocument( .sort((a, b) => a.name.localeCompare(b.name)), isTypeOnly: true, }); + } const clientClassDeclaration = mainFile.addClass({ name: pascalCase(schema.info.title, 'RestClient'),