-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go To Definition doesn't work for certain module patterns #12278
Comments
You have to |
When not in strict mode, I don't have to return a new constructor for my script to work.. |
Irregardless you need to call the function. |
Sorry - I do call the function (I just updated my test code). Please try it - you'll see that Go To Definition does not work. |
Indeed it does not work. module.exports = function (baseUrl) {
return {
apiCall: function (url, cb) {
let fullUrl = baseUrl + url;
}
};
}; The issue is that |
Would a |
no. the system currently does not track assignments to you could however, enhance the experience by using JSDoc comments: /**
* @return {{apiCall: (url, cb)=> string;}}
*/
module.exports = function (baseUrl) {
...
} |
I use a similar module pattern in an application I'm working on, and the lack of IntelliSense/definitions for those has been an issue for me as well. Mine follow this basic pattern: module.exports = function(x, y, z) {
var exports = {};
exports.method = function() {
// Something that might use x, y, or z
};
return exports;
} Would it be possible to do something like include an option in the jsconfig.json file to specify a property name or list of names to track when determining module exports? Maybe something like this? {
"moduleOptions": {
"exportProperty": ["exports", "this"]
}
} |
@abgivant, this pattern is actually an easier one to support, we already have plans to do so on the future. it is a general construction patter that is common in JS. |
@mhegazy Ah cool. Is that part of the "expando" discussion, or is there a more specific feature in the works for things like that? |
Let's move the latter discussion to the new issue #12416 |
@waderyan asked me to open up a bug in the TypeScript repo for my comment on this issue:
microsoft/vscode#15004
TypeScript Version: VSCode 1.7.1
Code
myfile.js:
Expected behavior:
If I
let test = require('myfile')(baseUrl)
thentest.apiCall(url, cb)
, I should be able to 'go to definition' on apiCall.Actual behavior:
Cannot go to definition.
The text was updated successfully, but these errors were encountered: