Skip to content
Permalink
Browse files
feat(51163): show QF to fill in the missing properties for the mapped…
… type. (#51165)
  • Loading branch information
a-tarasyuk committed Oct 13, 2022
1 parent bdcc240 commit cf1b6b73330eab2dd484d71cbdb662a83b3c726f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
@@ -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;
@@ -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: ""
});`,
});

0 comments on commit cf1b6b7

Please sign in to comment.