Skip to content

fix(59463): Feature that displays method argument names inline does not correctly handle method overloading #59504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/services/inlayHints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ import {
PrefixUnaryExpression,
PropertyDeclaration,
QuotePreference,
Signature,
SignatureDeclarationBase,
skipParentheses,
some,
Expand Down Expand Up @@ -296,11 +295,8 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
return;
}

const candidates: Signature[] = [];
const signature = checker.getResolvedSignatureForSignatureHelp(expr, candidates);
if (!signature || !candidates.length) {
return;
}
const signature = checker.getResolvedSignature(expr);
if (signature === undefined) return;

let signatureParamPos = 0;
for (const originalArg of args) {
Expand Down
18 changes: 18 additions & 0 deletions tests/baselines/reference/inlayHintsOverloadCall2.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// === Inlay Hints ===
{ n: [1, 2, 3] },
^
{
"text": "ok_1:",
"position": 195,
"kind": "Parameter",
"whitespaceAfter": true
}

{
^
{
"text": "ok_2:",
"position": 217,
"kind": "Parameter",
"whitespaceAfter": true
}
23 changes: 23 additions & 0 deletions tests/cases/fourslash/inlayHintsOverloadCall2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// <reference path="fourslash.ts" />

////type HasID = {
//// id: number;
////}
////
////type Numbers = {
//// n: number[];
////}
////
////declare function func(bad1: number, bad2: HasID): void;
////declare function func(ok_1: Numbers, ok_2: HasID): void;
////
////func(
//// { n: [1, 2, 3] },
//// {
//// id: 1,
//// },
////);

verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "all",
});