Skip to content

Commit 2db17fd

Browse files
authored
fix(48520): fix getting parameter type by index (#48521)
1 parent b1a25fd commit 2db17fd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/services/codefixes/fixAddMissingMember.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ namespace ts.codefix {
169169
const param = signature.parameters[argIndex].valueDeclaration;
170170
if (!(param && isParameter(param) && isIdentifier(param.name))) return undefined;
171171

172-
const properties = arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getTypeAtLocation(param), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
172+
const properties = arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
173173
if (!length(properties)) return undefined;
174174
return { kind: InfoKind.ObjectLiteral, token: param.name, properties, parentDeclaration: parent };
175175
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////type T = { foo: number };
4+
////const foo: T[] = [];
5+
////[|foo.push({ })|]
6+
7+
verify.codeFix({
8+
index: 0,
9+
description: ts.Diagnostics.Add_missing_properties.message,
10+
newRangeContent:
11+
`foo.push({
12+
foo: 0
13+
})`,
14+
});

0 commit comments

Comments
 (0)