mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 05:55:11 -05:00
feat(51163): show QF to fill in the missing properties for the mapped type. (#51165)
This commit is contained in:
@@ -178,7 +178,7 @@ namespace ts.codefix {
|
||||
const argIndex = findIndex(parent.parent.arguments, arg => arg === parent);
|
||||
if (argIndex < 0) return undefined;
|
||||
|
||||
const signature = singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), SignatureKind.Call));
|
||||
const signature = checker.getResolvedSignature(parent.parent);
|
||||
if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined;
|
||||
|
||||
const param = signature.parameters[argIndex].valueDeclaration;
|
||||
|
||||
27
tests/cases/fourslash/codeFixAddMissingProperties24.ts
Normal file
27
tests/cases/fourslash/codeFixAddMissingProperties24.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////interface A {
|
||||
//// a: number;
|
||||
//// b: string;
|
||||
////}
|
||||
////interface B {
|
||||
//// c: boolean;
|
||||
////}
|
||||
////interface C {
|
||||
//// a: A;
|
||||
//// b: B;
|
||||
////}
|
||||
////function f<T extends keyof C>(type: T, obj: C[T]): string {
|
||||
//// return "";
|
||||
////}
|
||||
////[|f("a", {});|]
|
||||
|
||||
verify.codeFix({
|
||||
index: 0,
|
||||
description: ts.Diagnostics.Add_missing_properties.message,
|
||||
newRangeContent:
|
||||
`f("a", {
|
||||
a: 0,
|
||||
b: ""
|
||||
});`,
|
||||
});
|
||||
Reference in New Issue
Block a user