From df9d16503f6755dd071e4c591b9d21c39d03d95e Mon Sep 17 00:00:00 2001 From: "Oleksandr T." Date: Sat, 19 Oct 2024 00:44:43 +0300 Subject: [PATCH] fix(59463): Feature that displays method argument names inline does not correctly handle method overloading (#59504) --- src/services/inlayHints.ts | 8 ++----- ...eline => inlayHintsOverloadCall1.baseline} | 0 .../inlayHintsOverloadCall2.baseline | 18 +++++++++++++++ ...loadCall.ts => inlayHintsOverloadCall1.ts} | 0 .../fourslash/inlayHintsOverloadCall2.ts | 23 +++++++++++++++++++ 5 files changed, 43 insertions(+), 6 deletions(-) rename tests/baselines/reference/{inlayHintsOverloadCall.baseline => inlayHintsOverloadCall1.baseline} (100%) create mode 100644 tests/baselines/reference/inlayHintsOverloadCall2.baseline rename tests/cases/fourslash/{inlayHintsOverloadCall.ts => inlayHintsOverloadCall1.ts} (100%) create mode 100644 tests/cases/fourslash/inlayHintsOverloadCall2.ts diff --git a/src/services/inlayHints.ts b/src/services/inlayHints.ts index a3e54cf2378..f5a29b332b5 100644 --- a/src/services/inlayHints.ts +++ b/src/services/inlayHints.ts @@ -106,7 +106,6 @@ import { PrefixUnaryExpression, PropertyDeclaration, QuotePreference, - Signature, SignatureDeclarationBase, skipParentheses, some, @@ -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) { diff --git a/tests/baselines/reference/inlayHintsOverloadCall.baseline b/tests/baselines/reference/inlayHintsOverloadCall1.baseline similarity index 100% rename from tests/baselines/reference/inlayHintsOverloadCall.baseline rename to tests/baselines/reference/inlayHintsOverloadCall1.baseline diff --git a/tests/baselines/reference/inlayHintsOverloadCall2.baseline b/tests/baselines/reference/inlayHintsOverloadCall2.baseline new file mode 100644 index 00000000000..37cb8b498eb --- /dev/null +++ b/tests/baselines/reference/inlayHintsOverloadCall2.baseline @@ -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 +} \ No newline at end of file diff --git a/tests/cases/fourslash/inlayHintsOverloadCall.ts b/tests/cases/fourslash/inlayHintsOverloadCall1.ts similarity index 100% rename from tests/cases/fourslash/inlayHintsOverloadCall.ts rename to tests/cases/fourslash/inlayHintsOverloadCall1.ts diff --git a/tests/cases/fourslash/inlayHintsOverloadCall2.ts b/tests/cases/fourslash/inlayHintsOverloadCall2.ts new file mode 100644 index 00000000000..2a9a0a91e75 --- /dev/null +++ b/tests/cases/fourslash/inlayHintsOverloadCall2.ts @@ -0,0 +1,23 @@ +/// + +////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", +});