Skip to content

Commit df9d165

Browse files
authored
fix(59463): Feature that displays method argument names inline does not correctly handle method overloading (#59504)
1 parent c07da58 commit df9d165

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

src/services/inlayHints.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ import {
106106
PrefixUnaryExpression,
107107
PropertyDeclaration,
108108
QuotePreference,
109-
Signature,
110109
SignatureDeclarationBase,
111110
skipParentheses,
112111
some,
@@ -296,11 +295,8 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
296295
return;
297296
}
298297

299-
const candidates: Signature[] = [];
300-
const signature = checker.getResolvedSignatureForSignatureHelp(expr, candidates);
301-
if (!signature || !candidates.length) {
302-
return;
303-
}
298+
const signature = checker.getResolvedSignature(expr);
299+
if (signature === undefined) return;
304300

305301
let signatureParamPos = 0;
306302
for (const originalArg of args) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// === Inlay Hints ===
2+
{ n: [1, 2, 3] },
3+
^
4+
{
5+
"text": "ok_1:",
6+
"position": 195,
7+
"kind": "Parameter",
8+
"whitespaceAfter": true
9+
}
10+
11+
{
12+
^
13+
{
14+
"text": "ok_2:",
15+
"position": 217,
16+
"kind": "Parameter",
17+
"whitespaceAfter": true
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////type HasID = {
4+
//// id: number;
5+
////}
6+
////
7+
////type Numbers = {
8+
//// n: number[];
9+
////}
10+
////
11+
////declare function func(bad1: number, bad2: HasID): void;
12+
////declare function func(ok_1: Numbers, ok_2: HasID): void;
13+
////
14+
////func(
15+
//// { n: [1, 2, 3] },
16+
//// {
17+
//// id: 1,
18+
//// },
19+
////);
20+
21+
verify.baselineInlayHints(undefined, {
22+
includeInlayParameterNameHints: "all",
23+
});

0 commit comments

Comments
 (0)