转到实现而不是 TypeScript 声明 [英] Go to implementation instead of TypeScript declaration

查看:46
本文介绍了转到实现而不是 TypeScript 声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 VSCode 中按住 Cmd 的同时单击导入的变量时,我经常最终查看该变量的 TypeScript 声明.有什么方法可以让 VSCode 带我去定义它吗?我自己不使用 TypeScript,因此该功能目前对我没有帮助.

When I click an imported variable while holding Cmd in VSCode, I often end up looking at the TypeScript declaration of that variable. Is there any way to have VSCode take me to the definition of it instead? I don't use TypeScript myself, so the feature isn't helpful to me right now.

推荐答案

经过大量搜索,我找到了一个简单的解决方案.

I found a simple solution for this after a lot of searching.

您只需将 "typescript.disableAutomaticTypeAcquisition": true 添加到您项目的 settings.json(或 vscode 的全局设置).

You just need to add "typescript.disableAutomaticTypeAcquisition": true to your project's settings.json (or vscode's global settings).

这将禁用 TypeScript 定义的自动生成并恢复原始的跳转到"去实现的行为.

This will disable the automatic generation of TypeScript definitions and restore the original "Jump to" behaviour of going to the implementation.

来源:https://ianwalter.dev/跳转到源定义而不是打字稿定义在 vs 代码

尽管作者提供了错误的说明(false 应该是 true,所以阅读帖子时要小心.也不需要重新安装节点模块.

The author provided the wrong instructions though (false when it should have been true so be careful when you read the post. Re-installing node modules was also not needed.

这篇关于转到实现而不是 TypeScript 声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆