Skip to content

Commit cf1b6b7

Browse files
authoredOct 13, 2022
feat(51163): show QF to fill in the missing properties for the mapped type. (#51165)
1 parent bdcc240 commit cf1b6b7

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
 

‎src/services/codefixes/fixAddMissingMember.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ namespace ts.codefix {
178178
const argIndex = findIndex(parent.parent.arguments, arg => arg === parent);
179179
if (argIndex < 0) return undefined;
180180

181-
const signature = singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), SignatureKind.Call));
181+
const signature = checker.getResolvedSignature(parent.parent);
182182
if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined;
183183

184184
const param = signature.parameters[argIndex].valueDeclaration;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////interface A {
4+
//// a: number;
5+
//// b: string;
6+
////}
7+
////interface B {
8+
//// c: boolean;
9+
////}
10+
////interface C {
11+
//// a: A;
12+
//// b: B;
13+
////}
14+
////function f<T extends keyof C>(type: T, obj: C[T]): string {
15+
//// return "";
16+
////}
17+
////[|f("a", {});|]
18+
19+
verify.codeFix({
20+
index: 0,
21+
description: ts.Diagnostics.Add_missing_properties.message,
22+
newRangeContent:
23+
`f("a", {
24+
a: 0,
25+
b: ""
26+
});`,
27+
});

0 commit comments

Comments
 (0)