From a91ca99b1f9f59b1fdbba40ea03e40ed22296ef9 Mon Sep 17 00:00:00 2001 From: ivanwonder Date: Wed, 4 Dec 2019 14:09:48 +0800 Subject: [PATCH] refactor(language-service): refactor the method TypeWrapper.name and PipeSymbol.selectSignature (#34177) PR Close #34177 --- .../src/typescript_symbols.ts | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/packages/language-service/src/typescript_symbols.ts b/packages/language-service/src/typescript_symbols.ts index f35df55316..d11b1e3e87 100644 --- a/packages/language-service/src/typescript_symbols.ts +++ b/packages/language-service/src/typescript_symbols.ts @@ -244,16 +244,7 @@ class TypeWrapper implements Symbol { } } - get name(): string { - const symbol = this.tsType.symbol; - if (symbol) { - return symbol.name; - } else { - // A primitive type (e.g. 'string') doesn't have Symbol, - // so use the ts.TypeChecker to get the type name. - return this.context.checker.typeToString(this.tsType); - } - } + get name(): string { return this.context.checker.typeToString(this.tsType); } public readonly kind: DeclarationKind = 'type'; @@ -617,15 +608,10 @@ class PipeSymbol implements Symbol { let resultType: ts.Type|undefined = undefined; switch (this.name) { case 'async': - switch (parameterType.name) { - case 'Observable': - case 'Promise': - case 'EventEmitter': - resultType = getTypeParameterOf(parameterType.tsType, parameterType.name); - break; - default: - resultType = getTsTypeFromBuiltinType(BuiltinType.Any, this.context); - break; + // Get symbol of 'Observable', 'Promise', or 'EventEmitter' type. + const symbol = parameterType.tsType.symbol; + if (symbol) { + resultType = getTypeParameterOf(parameterType.tsType, symbol.name); } break; case 'slice':