You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WebStorm中TypeScript类型hover不显示初始类型如何解决?

解决WebStorm复杂TypeScript类型悬停显示异常的问题

对齐TypeScript版本配置

  • 确保WebStorm使用项目本地的TypeScript版本:
    1. 打开File > Settings > Languages & Frameworks > TypeScript(Windows/Linux)或WebStorm > Settings > Languages & Frameworks > TypeScript(Mac)
    2. 在TypeScript version选项中,选择Node_modules下的项目本地版本,不要用WebStorm内置版本——复杂类型的解析能力和TS版本直接相关

开启类型预览优化选项

  • 调整WebStorm的文档弹窗设置:
    1. 进入File > Settings > Editor > General > Code Completion
    2. 勾选Show full signatures in documentation popup
    3. 再进入File > Settings > Editor > General > Appearance,确认Show quick documentation on mouse move已开启,延迟设置为500ms左右即可

重启TypeScript服务或清除缓存

  • 如果设置调整后仍无效,手动刷新服务:
    1. 点击右下角状态栏的TypeScript图标(未显示的话,可通过View > Appearance > Status Bar Widgets调出)
    2. 选择Restart TypeScript Service
    3. 若还是没效果,使用File > Invalidate Caches... > Invalidate and Restart清除缓存并重启IDE

验证结果

调整完成后,再次悬停TransformedFruit,就能看到正确解析后的最终类型:

type TransformedFruit = {
    apple: "apple";
    banana: "banana";
    orange: "orange";
};

内容的提问来源于stack exchange,提问作者Pieter-Jan De Bruyne

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 07:17:09