Skip to content

Commit

Permalink
fix(typescript) do not create unions for enums and fix imports (#33)
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman authored Jun 6, 2023
1 parent bd7466a commit 1200c2c
Show file tree
Hide file tree
Showing 2 changed files with 4,583 additions and 4,589 deletions.
4 changes: 2 additions & 2 deletions lib/codegen/fromcto/typescript/typescriptvisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class TypescriptVisitor {
if (!properties.has(typeNamespace)) {
properties.set(typeNamespace, new Set());
}
properties.get(typeNamespace).add(`I${typeName}`);
properties.get(typeNamespace).add(property.isTypeEnum?.() ? typeName : `I${typeName}`);
}
});

Expand Down Expand Up @@ -208,7 +208,7 @@ class TypescriptVisitor {
const subclasses = classDeclaration.getDirectSubclasses();
if (subclasses && subclasses.length > 0) {
parameters.fileWriter.writeLine(0, 'export type ' + classDeclaration.getName() +
'Union = ' + subclasses.map(subclass => `I${subclass.getName()}`).join(' | \n') + ';\n');
'Union = ' + subclasses.filter(declaration => !declaration.isEnum()).map(subclass => `I${subclass.getName()}`).join(' | \n') + ';\n');
}
return null;
}
Expand Down
Loading

0 comments on commit 1200c2c

Please sign in to comment.