Skip to content

Commit

Permalink
fix: avoid adding empty type only imports
Browse files Browse the repository at this point in the history
  • Loading branch information
maxholman committed Jul 20, 2024
1 parent 87d5203 commit 48d45c2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/process-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,16 +626,20 @@ 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: T | 'void'): t is T => t !== 'void')
.map((t) => ({
name: t.getName(),
}))
.sort((a, b) => a.name.localeCompare(b.name)),
isTypeOnly: true,
});
}

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

0 comments on commit 48d45c2

Please sign in to comment.