[英]vscode does not jump to definition
I have a node project that uses ws. 我有一个使用ws的节点项目。 VSCode knows about the websocket events and functions but if I add something to prototype then it is recognized in suggestions but I can't jump to definition.
VSCode知道websocket的事件和功能,但是如果我在原型中添加一些内容,那么它会在建议中被识别出来,但是我无法跳转到定义。 It say: No definition found for 'setDefaults' .
它说: 找不到'setDefaults'的定义 。 Is there something I need to configure in VScode to work or am I using it wrong?
我需要在VScode中进行配置才能正常工作还是我使用错了吗?
The source to easy copy: 易于复制的来源:
const WebSocket = require('ws');
WebSocket.prototype.setDefaults = function()
{
console.log("defaults")
}
ws = new WebSocket();
ws.setDefaults()
I also tried Find all references, but it does not find the usage of the method. 我还尝试了“查找所有引用”,但找不到该方法的用法。
You are running into this known limitation around dynamic properties 您正在遇到有关动态属性的已知限制
One workaround: use jsdocs to declare a new type that includes your extension method: 一种解决方法:使用jsdocs声明一个包含扩展方法的新类型:
const WebSocket = require('ws')
/**
* @typedef {{ setDefaults: () => void }} WebSocketExtensions
* @typedef {WebSocket & WebSocketExtensions} ExtendedWebsocket
*
* @type {ExtendedWebsocket}
*/
const ws = new WebSocket();
ws.setDefaults()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.