microsoft / microsoft/TypeScript

On TypeScript 7, Call hierarchy shows a full absolute path instead of file name + relative path

未关闭
#64,097 1 条评论 10 个 reaction 已指派 2 人 在 GitHub 查看

@RyanCavanaugh 已经在做这个了。

开始于 2026年8月31日。

  • #64108 来自 @copilot-swe-agent —— 未关闭
Bug
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

🔎 Search Terms

"call hierarchy"
"function call hierarchy files"
"call hierarchy file path"
"absolute path"
"full file path"

Found: Possibly related #36511 — same symptom, reported in 2020 and closed as fixed.

🕗 Version & Regression Information
  • Work as expected on 6.0.3: TypeScript and JavaScript Language Features (built-in)
  • Bug on TypeScriptTeam.native-preview 0.20260226.1 (first version with Call Hierarchy support)
  • Bug on TypeScriptTeam.native-preview 0.20260708.2 (latest)
⏯ Playground Link

https://github.com/brian-xu-vlt/typescript-hierarchy-repro

💻 Code

[!IMPORTANT]
I provided a repository above because the playground does not seem to support show call hierarchy on a symbol in order to reproduce the bug, but below is the playground code form the provided repository in case it helps

callers.ts

import { targetFunction } from "./target.js";

export const levelOne = (value: number): number => {
  return targetFunction(value);
};

function levelTwo(value: number): number {
  return levelOne(value);
}

const { levelThree } = {
  levelThree: (value: number): number => {
    return levelTwo(value);
  },
};

const levelFour = (value: number): void => {
  console.log(levelThree(42));
};

target.ts

export function targetFunction(value: number): number {
  return value * 2;
}
🙁 Actual behavior

Steps to reproduce

  1. Clone this repo (https://github.com/brian-xu-vlt/typescript-hierarchy-repro) and run pnpm install.
  2. Open src/target.ts.
  3. On targetFunction (line 1) Run Show Call Hierarchy (Shift+Alt+H) and expand the incoming calls
    down to the last level.
    🚨 → See the issue: The hierarchy is targetFunctionlevelOnelevelTwo, then a node for the
    containing file with a full path. That last node is where the two TS versions differ.
Image
🙂 Expected behavior

The file node is labelled the way TypeScript 6 labels it: the file name, with
the path relative to the workspace shown as the secondary detail.

Image
Additional information about the issue

Real life issue

For a simple call the issue is benign, but in real monorepos, a list of many absolute paths make it very hard to navigate the call hierarchy.

Image

Language server likely not the root cause

The reproduction repository contains a simple script to show tsserver and TypeScript 7 LSP server produce the same value, meaning the issue is quite likely to come from TypeScriptTeam.native-preview

Show to run

# with typescript 6.0.3 installed, over the tsserver JSON protocol
node tools/callhierarchy.mjs ./src/target.ts targetFunction --depth 10 --engine tsserver

# with typescript 7.0.2 installed, over LSP
node tools/callhierarchy.mjs ./src/target.ts targetFunction --depth 10 --engine lsp

Result for TS6 and TS7

Image

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。