Skip to content

Commit 48d45c2

Browse files
committed
fix: avoid adding empty type only imports
1 parent 87d5203 commit 48d45c2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/process-document.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,16 +626,20 @@ export async function processOpenApiDocument(
626626
],
627627
});
628628

629+
const namedImports = [...new Set([...inputTypes, ...outputTypes])];
630+
631+
if (namedImports.length > 0) {
629632
mainFile.addImportDeclaration({
630633
moduleSpecifier: typesModuleSpecifier,
631-
namedImports: [...new Set([...inputTypes, ...outputTypes])]
634+
namedImports: namedImports
632635
.filter(<T>(t: T | 'void'): t is T => t !== 'void')
633636
.map((t) => ({
634637
name: t.getName(),
635638
}))
636639
.sort((a, b) => a.name.localeCompare(b.name)),
637640
isTypeOnly: true,
638641
});
642+
}
639643

640644
const clientClassDeclaration = mainFile.addClass({
641645
name: pascalCase(schema.info.title, 'RestClient'),

0 commit comments

Comments
 (0)