Skip to content

Commit

Permalink
fix(deps): support self-defined type
Browse files Browse the repository at this point in the history
fix #267
  • Loading branch information
vogloblinsky committed Sep 8, 2017
1 parent c29204c commit 104b82f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dist/index-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3578,6 +3578,11 @@ var Dependencies = /** @class */ (function () {
if (node.type.types[i].kind === ts$3.SyntaxKind.LiteralType && node.type.types[i].literal) {
_return += '"' + node.type.types[i].literal.text + '"';
}
if (typeof node.type.types[i].typeName !== 'undefined') {
if (typeof node.type.types[i].typeName.escapedText !== 'undefined') {
_return += node.type.types[i].typeName.escapedText;
}
}
if (i < len - 1) {
_return += ' | ';
}
Expand Down
5 changes: 5 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3578,6 +3578,11 @@ var Dependencies = /** @class */ (function () {
if (node.type.types[i].kind === ts$3.SyntaxKind.LiteralType && node.type.types[i].literal) {
_return += '"' + node.type.types[i].literal.text + '"';
}
if (typeof node.type.types[i].typeName !== 'undefined') {
if (typeof node.type.types[i].typeName.escapedText !== 'undefined') {
_return += node.type.types[i].typeName.escapedText;
}
}
if (i < len - 1) {
_return += ' | ';
}
Expand Down
7 changes: 7 additions & 0 deletions src/app/compiler/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,13 @@ export class Dependencies {
if (node.type.types[i].kind === ts.SyntaxKind.LiteralType && node.type.types[i].literal) {
_return += '"' + node.type.types[i].literal.text + '"';
}

if (typeof node.type.types[i].typeName !== 'undefined') {
if (typeof node.type.types[i].typeName.escapedText !== 'undefined') {
_return += node.type.types[i].typeName.escapedText;
}
}

if (i<len-1) {
_return += ' | ';
}
Expand Down
7 changes: 7 additions & 0 deletions test/src/cli/cli-generation-big-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,11 @@ describe('CLI simple generation - big app', () => {
expect(file).to.contain('../classes/Todo.html#completed');
});

it('should support self-defined type', () => {
let file = read('documentation/classes/Todo.html');
expect(file).to.contain('../miscellaneous/typealiases.html#PopupPosition');
file = read('documentation/miscellaneous/typealiases.html');
expect(file).to.contain('<code>ElementRef | HTMLElement</code>');
});

});
8 changes: 8 additions & 0 deletions test/src/todomvc-ng2/src/app/shared/models/todo.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
ElementRef
} from "@angular/core";

import { Direction } from '../miscellaneous/miscellaneous';

export class Tada {
Expand All @@ -18,6 +22,8 @@ export class Todo extends Tada {
*/
editing: boolean;

pos?: PopupPosition;

[index: number]: string;

testCommentFunction(dig: number, str: string, bool: boolean): object {
Expand Down Expand Up @@ -65,3 +71,5 @@ export class Todo extends Tada {
return 5;
}
}

export type PopupPosition = ElementRef | HTMLElement;

0 comments on commit 104b82f

Please sign in to comment.