Skip to content

Commit 26fbd15

Browse files
jiayihublakeembrey
authored andcommitted
Add typeArguments to ReferenceType#toString() (#396)
1 parent 75db29c commit 26fbd15

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lib/models/types/reference.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,18 @@ export class ReferenceType extends Type
113113

114114
/**
115115
* Return a string representation of this type.
116+
* @example EventEmitter<any>
116117
*/
117118
toString() {
118-
if (this.reflection) {
119-
return this.reflection.name + (this.isArray ? '[]' : '');
120-
} else {
121-
return this.name + (this.isArray ? '[]' : '');
119+
var name = this.reflection ? this.reflection.name : this.name;
120+
var arraySuffix = this.isArray ? '[]' : '';
121+
var typeArgs = '';
122+
if (this.typeArguments) {
123+
typeArgs += '<';
124+
typeArgs += this.typeArguments.map(arg => arg.toString()).join(', ');
125+
typeArgs += '>'
122126
}
127+
128+
return name + typeArgs + arraySuffix;
123129
}
124130
}

0 commit comments

Comments
 (0)