TypeScript 界面不会在 VS Code 悬停小部件或 ctrl-k-i 上显示其属性

2024-05-11

当我在 VS Code 中创建任何界面时,界面内没有任何方法的预览。当我使用类型声明时,它会按预期工作。

interface SomeInterface {
    someMethod: string
}

let test: SomeInterface = {
    
};

我了解(并同意)所描述的行为here https://stackoverflow.com/questions/61851075/typescript-extending-interfaces-and-hover-hints但是,这似乎对我不起作用。

我尝试在方法上方创建 JSDoc 描述(未显示描述或方法)。

目前的解决方法:

  • 按住 Alt 预览完整声明(这并不理想,因为它不能与无需使用鼠标即可显示弹出窗口的 Ctrl-k-i 热键一起使用)。
  • 构造对象时按 Ctrl-Space 激活 IntelliSense 建议。
  • use peek跳转到接口声明。

You can get the properties listing (structural view as opposed to nominal view) if you hold ctrl/cmd while hovering over the interface name with your mouse. Note that it will only show properties defined on the interface and not including properties defined on interfaces that said interface extends. If you actually want to get the properties listing without holding ctrl/cmd, then read on...

这是一个已知的问题”。 VS 代码的TypeScript 支持 https://github.com/microsoft/vscode/tree/main/extensions/typescript-language-features直接构建在 TypeScript 本身之上。请参阅 TypeScript GitHub 存储库上的建议问题票证:Intellisense 应在悬停时显示接口声明的内部结构 #38040 https://github.com/microsoft/TypeScript/issues/38040。在此期间您可以执行以下操作:

  • 对该问题单点赞以表示支持,并订阅它以获取有关讨论和进展的通知。
  • 建设性地参与开放式设计讨论。对于接口扩展等重要情况应该发生什么,仍然存在开放的设计讨论(source https://github.com/microsoft/TypeScript/issues/38040#issuecomment-616805979)。阅读有关设计决策的现有讨论,并尝试对其做出建设性贡献(包括为您的建议提供理由)。但请不要发表“+1”/“bump”之类的吵闹评论。
  • 您可以加倍努力,贡献该功能的 Pull Request 起草实现。

供您参考/学习目的,我通过谷歌搜索找到了问题票“github vscode issues hover typescript interface show properties".

另一个相关问题票:能够配置 IntelliSense 在悬停时显示的快速信息(例如是否展开) #56010 https://github.com/microsoft/TypeScript/issues/56010.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

TypeScript 界面不会在 VS Code 悬停小部件或 ctrl-k-i 上显示其属性 的相关文章

随机推荐