refactor(language-service): refactor the method TypeWrapper.name and PipeSymbol.selectSignature (#34177)
PR Close #34177
This commit is contained in:
parent
7a86a32040
commit
a91ca99b1f
|
@ -244,16 +244,7 @@ class TypeWrapper implements Symbol {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get name(): string {
|
get name(): string { return this.context.checker.typeToString(this.tsType); }
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly kind: DeclarationKind = 'type';
|
public readonly kind: DeclarationKind = 'type';
|
||||||
|
|
||||||
|
@ -617,15 +608,10 @@ class PipeSymbol implements Symbol {
|
||||||
let resultType: ts.Type|undefined = undefined;
|
let resultType: ts.Type|undefined = undefined;
|
||||||
switch (this.name) {
|
switch (this.name) {
|
||||||
case 'async':
|
case 'async':
|
||||||
switch (parameterType.name) {
|
// Get symbol of 'Observable', 'Promise', or 'EventEmitter' type.
|
||||||
case 'Observable':
|
const symbol = parameterType.tsType.symbol;
|
||||||
case 'Promise':
|
if (symbol) {
|
||||||
case 'EventEmitter':
|
resultType = getTypeParameterOf(parameterType.tsType, symbol.name);
|
||||||
resultType = getTypeParameterOf(parameterType.tsType, parameterType.name);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
resultType = getTsTypeFromBuiltinType(BuiltinType.Any, this.context);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'slice':
|
case 'slice':
|
||||||
|
|
Loading…
Reference in New Issue