Skip to content

Commit

Permalink
fix(deps): union type with generics
Browse files Browse the repository at this point in the history
fix #501
  • Loading branch information
vogloblinsky committed Mar 9, 2018
1 parent 63d97e5 commit eec9c4b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/app/compiler/deps/helpers/class-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,15 @@ export class ClassHelper {
if (type.typeName) {
_return += this.visitTypeName(type.typeName);
}
if (type.typeArguments) {
_return += '<';
const typeArguments = [];
for (const argument of type.typeArguments) {
typeArguments.push(this.visitType(argument));
}
_return += typeArguments.join(' | ');
_return += '>';
}
}
if (i < len - 1) {
_return += ' | ';
Expand Down Expand Up @@ -677,7 +686,6 @@ export class ClassHelper {
}
_return += '>';
}

return _return;
}

Expand Down
5 changes: 5 additions & 0 deletions test/src/cli/cli-generation-big-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,9 @@ describe('CLI simple generation - big app', () => {
let file = read(distFolder + '/miscellaneous/typealiases.html');
expect(file).to.contain('<code>number | string | (number | string)[]</code>');
});

it('should support union type with generic', () => {
let file = read(distFolder + '/miscellaneous/typealiases.html');
expect(file).to.contain('<code>Type&lt;TableCellRendererBase&gt; | TemplateRef&lt;any&gt;</code>');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ export let yo:{ [index:string] : {message: string} } = {};

export type ChartChange = "creating" | "created" | "updating" | "updated";

export type TableColumnTarget = number | string | (number | string)[];
export type TableColumnTarget = number | string | (number | string)[];

export type TableSyncRenderer = Type<TableCellRendererBase> | TemplateRef<any>;

0 comments on commit eec9c4b

Please sign in to comment.