mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
fix(48520): fix getting parameter type by index (#48521)
This commit is contained in:
parent
b1a25fd8b1
commit
2db17fdda2
@ -169,7 +169,7 @@ namespace ts.codefix {
|
||||
const param = signature.parameters[argIndex].valueDeclaration;
|
||||
if (!(param && isParameter(param) && isIdentifier(param.name))) return undefined;
|
||||
|
||||
const properties = arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getTypeAtLocation(param), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
|
||||
const properties = arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
|
||||
if (!length(properties)) return undefined;
|
||||
return { kind: InfoKind.ObjectLiteral, token: param.name, properties, parentDeclaration: parent };
|
||||
}
|
||||
|
||||
14
tests/cases/fourslash/codeFixAddMissingProperties20.ts
Normal file
14
tests/cases/fourslash/codeFixAddMissingProperties20.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////type T = { foo: number };
|
||||
////const foo: T[] = [];
|
||||
////[|foo.push({ })|]
|
||||
|
||||
verify.codeFix({
|
||||
index: 0,
|
||||
description: ts.Diagnostics.Add_missing_properties.message,
|
||||
newRangeContent:
|
||||
`foo.push({
|
||||
foo: 0
|
||||
})`,
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user