mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
use getBaseTypeOfLiteralType
This commit is contained in:
parent
150e2fbf50
commit
d9e0fffad9
@ -83,7 +83,7 @@ namespace ts {
|
||||
getSignaturesOfType,
|
||||
getIndexTypeOfType,
|
||||
getBaseTypes,
|
||||
getWidenedType,
|
||||
getBaseTypeOfLiteralType,
|
||||
getTypeFromTypeNode,
|
||||
getParameterType: getTypeAtPosition,
|
||||
getReturnTypeOfSignature,
|
||||
|
||||
@ -2382,7 +2382,7 @@
|
||||
getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
|
||||
getBaseTypes(type: InterfaceType): BaseType[];
|
||||
getWidenedType(type: Type): Type;
|
||||
getBaseTypeOfLiteralType(type: Type): Type;
|
||||
getReturnTypeOfSignature(signature: Signature): Type;
|
||||
/**
|
||||
* Gets the type of a parameter at a given position in a signature.
|
||||
|
||||
@ -30,6 +30,22 @@ namespace ts.codefix {
|
||||
|
||||
// if function call, synthesize function declaration
|
||||
if(token.parent.parent.kind == SyntaxKind.CallExpression) {
|
||||
const callExpression = token.parent.parent as CallExpression;
|
||||
if(callExpression.typeArguments) {
|
||||
/**
|
||||
* We can't in general know which arguments should use the type of the expression
|
||||
* or the type of the type argument in the declaration. Consider
|
||||
* ```
|
||||
* class A {
|
||||
* constructor(a: number){
|
||||
* this.foo<number>(a,1,true);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -41,8 +57,8 @@ namespace ts.codefix {
|
||||
binaryExpression.operatorToken;
|
||||
|
||||
const checker = context.program.getTypeChecker();
|
||||
const type = checker.getWidenedType(checker.getTypeAtLocation(binaryExpression.right));
|
||||
typeString = checker.typeToString(type);
|
||||
const widenedType = checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right));
|
||||
typeString = checker.typeToString(widenedType);
|
||||
}
|
||||
|
||||
return [{
|
||||
|
||||
@ -78,6 +78,7 @@
|
||||
"formatting/smartIndenter.ts",
|
||||
"formatting/tokenRange.ts",
|
||||
"codeFixProvider.ts",
|
||||
"codefixes/fixAddMissingMember.ts",
|
||||
"codefixes/fixExtendsInterfaceBecomesImplements.ts",
|
||||
"codefixes/fixClassIncorrectlyImplementsInterface.ts",
|
||||
"codefixes/fixClassDoesntImplementInheritedAbstractMember.ts",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user