Skip to content

Commit

Permalink
fix(59463): Feature that displays method argument names inline does n…
Browse files Browse the repository at this point in the history
…ot correctly handle method overloading (#59504)
  • Loading branch information
a-tarasyuk authored Oct 18, 2024
1 parent c07da58 commit df9d165
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
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",
});

0 comments on commit df9d165

Please sign in to comment.