Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 cf1b6b7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/codefixes/fixAddMissingMember.ts
Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions tests/cases/fourslash/codeFixAddMissingProperties24.ts
@@ -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.