From 146c904a004736d2718069742fd3dcd4b583f7e9 Mon Sep 17 00:00:00 2001 From: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com> Date: Wed, 18 Nov 2026 19:42:32 +0000 Subject: [PATCH 1/5] Initial plan From 291f5a90717169707d0eb18d6222f008034abd81 Mon Sep 17 00:00:00 2001 From: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com> Date: Wed, 18 Nov 2026 19:50:19 +0000 Subject: [PATCH 2/5] Fix duplicate call hierarchy ranges Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .../tests/callHierarchyInterfaceMethod_test.go | 11 +++++++++++ tsc/internal/ls/callhierarchy.go | 2 ++ 2 files changed, 13 insertions(+) diff --git a/tsc/internal/fourslash/tests/callHierarchyInterfaceMethod_test.go b/tsc/internal/fourslash/tests/callHierarchyInterfaceMethod_test.go index 3917092b3507d..ac082a27c8223 100644 --- a/tsc/internal/fourslash/tests/callHierarchyInterfaceMethod_test.go +++ b/tsc/internal/fourslash/tests/callHierarchyInterfaceMethod_test.go @@ -22,3 +22,14 @@ obj.foo();` f.GoToMarker(t, "") f.VerifyBaselineCallHierarchy(t) } + +func TestCallHierarchyOutgoingInterfaceMethod(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface G { m(): void; } +function /**/probe(g: G) { g.m(); }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/tsc/internal/ls/callhierarchy.go b/tsc/internal/ls/callhierarchy.go index 140e2da205b20..133b20d375acc 100644 --- a/tsc/internal/ls/callhierarchy.go +++ b/tsc/internal/ls/callhierarchy.go @@ -622,6 +622,7 @@ func (l *LanguageService) convertCallSiteGroupToIncomingCall(program *compiler.P } slices.SortFunc(fromRanges, lsproto.CompareRanges) + fromRanges = slices.Compact(fromRanges) return &lsproto.CallHierarchyIncomingCall{ From: from, @@ -992,6 +993,7 @@ func (l *LanguageService) convertCallSiteGroupToOutgoingCall(program *compiler.P } slices.SortFunc(fromRanges, lsproto.CompareRanges) + fromRanges = slices.Compact(fromRanges) return &lsproto.CallHierarchyOutgoingCall{ To: to, From 4a410ad8c01c079466caf61fbae404ace1076ea6 Mon Sep 17 00:00:00 2001 From: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com> Date: Wed, 18 Nov 2026 20:03:14 +0000 Subject: [PATCH 3/5] Add call hierarchy regression baseline Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...yOutgoingInterfaceMethod.callHierarchy.txt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tsc/testdata/baselines/reference/fourslash/callHierarchy/callHierarchyOutgoingInterfaceMethod.callHierarchy.txt diff --git a/tsc/testdata/baselines/reference/fourslash/callHierarchy/callHierarchyOutgoingInterfaceMethod.callHierarchy.txt b/tsc/testdata/baselines/reference/fourslash/callHierarchy/callHierarchyOutgoingInterfaceMethod.callHierarchy.txt new file mode 100644 index 0000000000000..e380dc6b110fd --- /dev/null +++ b/tsc/testdata/baselines/reference/fourslash/callHierarchy/callHierarchyOutgoingInterfaceMethod.callHierarchy.txt @@ -0,0 +1,36 @@ +// === Call Hierarchy === +╭ name: probe +├ kind: function +├ file: /callHierarchyOutgoingInterfaceMethod.ts +├ span: +│ ╭ /callHierarchyOutgoingInterfaceMethod.ts:2:1-2:32 +│ │ 2: function probe(g: G) { g.m(); } +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyOutgoingInterfaceMethod.ts:2:10-2:15 +│ │ 2: function probe(g: G) { g.m(); } +│ │ ^^^^^ +│ ╰ +├ incoming: none +├ outgoing: +│ ╭ to: +│ │ ╭ name: m +│ │ ├ kind: method +│ │ ├ file: /callHierarchyOutgoingInterfaceMethod.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyOutgoingInterfaceMethod.ts:1:15-1:25 +│ │ │ │ 1: interface G { m(): void; } +│ │ │ │ ^^^^^^^^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyOutgoingInterfaceMethod.ts:1:15-1:16 +│ │ │ │ 1: interface G { m(): void; } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyOutgoingInterfaceMethod.ts:2:24-2:27 +│ │ │ 2: function probe(g: G) { g.m(); } +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file From 08a458257c299c129510e56bc805c5a8053b8e48 Mon Sep 17 00:00:00 2001 From: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com> Date: Thu, 19 Nov 2026 00:50:04 +0000 Subject: [PATCH 4/5] Avoid duplicate call-site collection Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tsc/internal/ls/callhierarchy.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tsc/internal/ls/callhierarchy.go b/tsc/internal/ls/callhierarchy.go index 133b20d375acc..8b6154b56d1b8 100644 --- a/tsc/internal/ls/callhierarchy.go +++ b/tsc/internal/ls/callhierarchy.go @@ -806,6 +806,25 @@ func (c *callSiteCollector) recordCallSite(node *ast.Node) { } } +func isCallSiteTarget(node *ast.Node) bool { + parent := node.Parent + if parent == nil { + return false + } + + switch { + case ast.IsCallOrNewExpression(parent): + return parent.Expression() == node + case ast.IsTaggedTemplateExpression(parent): + return parent.AsTaggedTemplateExpression().Tag == node + case ast.IsDecorator(parent): + return parent.Expression() == node + case ast.IsJsxOpeningElement(parent), ast.IsJsxSelfClosingElement(parent): + return parent.TagName() == node + } + return false +} + func (c *callSiteCollector) collect(node *ast.Node) { if node == nil { return @@ -883,7 +902,9 @@ func (c *callSiteCollector) collect(node *ast.Node) { c.collect(node.Expression()) return case ast.KindPropertyAccessExpression, ast.KindElementAccessExpression: - c.recordCallSite(node) + if !isCallSiteTarget(node) { + c.recordCallSite(node) + } node.ForEachChild(func(child *ast.Node) bool { c.collect(child) return false @@ -993,7 +1014,6 @@ func (l *LanguageService) convertCallSiteGroupToOutgoingCall(program *compiler.P } slices.SortFunc(fromRanges, lsproto.CompareRanges) - fromRanges = slices.Compact(fromRanges) return &lsproto.CallHierarchyOutgoingCall{ To: to, From fe07e618e00f704a083bbfef8a58509f18b558db Mon Sep 17 00:00:00 2001 From: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com> Date: Thu, 19 Nov 2026 01:10:38 +0000 Subject: [PATCH 5/5] Restore outgoing range compaction Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tsc/internal/ls/callhierarchy.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tsc/internal/ls/callhierarchy.go b/tsc/internal/ls/callhierarchy.go index 8b6154b56d1b8..d39a693fab467 100644 --- a/tsc/internal/ls/callhierarchy.go +++ b/tsc/internal/ls/callhierarchy.go @@ -1014,6 +1014,7 @@ func (l *LanguageService) convertCallSiteGroupToOutgoingCall(program *compiler.P } slices.SortFunc(fromRanges, lsproto.CompareRanges) + fromRanges = slices.Compact(fromRanges) return &lsproto.CallHierarchyOutgoingCall{ To: to,