V
V
Vizer2019-03-29 17:57:44
JavaScript
Vizer, 2019-03-29 17:57:44

Is it possible in VS Code to make Go To Defenition work for JS with ambiguous definitions?

Faced strange behavior of the Go To Defenition function in VS Code.
Having a function call, I want to jump to its definition. In WebStorm, this is done using the Ctrl + Click combination on the function name. In VS Code, I use the F12 key for this, however, for most function calls I get "No definition found".
Example 1:
When trying to navigate to the definition of foo on line 7, I expect the cursor to move to line 5, but I get a "No definition found" error.

var helper = {
  SOME_CONST: 2
};

helper.foo = function() {} //<= сюда
helper.bar = function() {
  this.foo(); //=> отсюда
}

Example 2:
When trying to jump to the _helper definition on line 9, I expect the cursor to be moved to line 13, but I get a "No definition found" error.
var FooBarClass = function () {

};

FooBarClass.prototype.doJob = function() {
  var arr = [0, 1, 2];

  arr.map(function() {
    this._helper(); //=> отсюда
  }, this);
}

FooBarClass.prototype._helper = function() { //<= сюда

}

Is there a way to force the editor to find the definition (plugin, settings, or other means), or is this behavior built into it by design and nothing can be done about it?
Editor version 1.32.3, built-in TypeScript and JavaScript plugins included.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question