Skip to content

Commit

Permalink
feat: support union types
Browse files Browse the repository at this point in the history
  • Loading branch information
R-unic committed Oct 1, 2023
1 parent 45f1e6a commit 2905501
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/code-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
LiteralLikeNode,
StringLiteral,
TypeNode,
ArrayLiteralExpression,
UnionTypeNode,
ArrayTypeNode,
ArrayLiteralExpression,
TypeAliasDeclaration,
ModifierLike,
TypeReferenceNode,
Expand Down Expand Up @@ -1282,6 +1283,15 @@ export default class CodeGenerator extends StringBuilder {

private walkType(type: TypeNode): void {
switch(type.kind) {
case SyntaxKind.UnionType: {
const union = <UnionTypeNode>type;
for (const type of union.types) {
this.walk(type);
if (Util.isNotLast(type, union.types))
this.append(" | ");
}
break;
}
case SyntaxKind.NumberKeyword: {
this.append("Num");
break;
Expand Down

0 comments on commit 2905501

Please sign in to comment.