Skip to content

Commit

Permalink
fix(writers): remove import if type or interface already in the file
Browse files Browse the repository at this point in the history
  • Loading branch information
anymaniax committed Oct 28, 2022
1 parent a38b73d commit 12a7cfe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/writers/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ const getSchema = ({
header: string;
}): string => {
let file = header;
file += generateImports({ imports, target, isRootKey, specsName });
file += generateImports({
imports: imports.filter(
(imp) =>
!model.includes(`type ${imp.alias || imp.name} =`) &&
!model.includes(`interface ${imp.alias || imp.name} {`),
),
target,
isRootKey,
specsName,
});
file += imports.length ? '\n\n' : '\n';
file += model;
return file;
Expand Down

0 comments on commit 12a7cfe

Please sign in to comment.