feat(51163): show QF to fill in the missing properties for the mapped type. (#51165)

This commit is contained in:
Oleksandr T
2022-10-13 21:29:18 +03:00
committed by GitHub
parent bdcc240d68
commit cf1b6b7333
2 changed files with 28 additions and 1 deletions

View File

@@ -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;

View 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: ""
});`,
});