Skip to content

Commit a91ca99

Browse files
ivanwonderAndrewKushnir
authored andcommitted
refactor(language-service): refactor the method TypeWrapper.name and PipeSymbol.selectSignature (angular#34177)
PR Close angular#34177
1 parent 7a86a32 commit a91ca99

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

packages/language-service/src/typescript_symbols.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,7 @@ class TypeWrapper implements Symbol {
244244
}
245245
}
246246

247-
get name(): string {
248-
const symbol = this.tsType.symbol;
249-
if (symbol) {
250-
return symbol.name;
251-
} else {
252-
// A primitive type (e.g. 'string') doesn't have Symbol,
253-
// so use the ts.TypeChecker to get the type name.
254-
return this.context.checker.typeToString(this.tsType);
255-
}
256-
}
247+
get name(): string { return this.context.checker.typeToString(this.tsType); }
257248

258249
public readonly kind: DeclarationKind = 'type';
259250

@@ -617,15 +608,10 @@ class PipeSymbol implements Symbol {
617608
let resultType: ts.Type|undefined = undefined;
618609
switch (this.name) {
619610
case 'async':
620-
switch (parameterType.name) {
621-
case 'Observable':
622-
case 'Promise':
623-
case 'EventEmitter':
624-
resultType = getTypeParameterOf(parameterType.tsType, parameterType.name);
625-
break;
626-
default:
627-
resultType = getTsTypeFromBuiltinType(BuiltinType.Any, this.context);
628-
break;
611+
// Get symbol of 'Observable', 'Promise', or 'EventEmitter' type.
612+
const symbol = parameterType.tsType.symbol;
613+
if (symbol) {
614+
resultType = getTypeParameterOf(parameterType.tsType, symbol.name);
629615
}
630616
break;
631617
case 'slice':

0 commit comments

Comments
 (0)