fix(48520): fix getting parameter type by index (#48521)

This commit is contained in:
Oleksandr T 2022-04-04 07:42:37 +03:00 committed by GitHub
parent b1a25fd8b1
commit 2db17fdda2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -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 };
}

View 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
})`,
});