fix(language-service): return the js primitive type name (#34177)

PR Close #34177
This commit is contained in:
ivanwonder 2019-12-02 15:37:03 +08:00 committed by Andrew Kushnir
parent 2ebaa51514
commit 148a060daa
1 changed files with 7 additions and 1 deletions

View File

@ -246,7 +246,13 @@ class TypeWrapper implements Symbol {
get name(): string {
const symbol = this.tsType.symbol;
return (symbol && symbol.name) || '<anonymous>';
if (symbol) {
return symbol.name;
} else {
// the js primitive type(e.g. 'string') doesn't have Symbol.
// use the ts.TypeChecker to get the type name.
return this.context.checker.typeToString(this.tsType);
}
}
public readonly kind: DeclarationKind = 'type';