-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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 #15004
Comments
+1. I typically use:
'Go to definition' does not work when I require the file containing this function. |
@bowdenk7 would you call this an expando pattern limitation? |
Yes and no... the way we do commonJS module resolution is by looking explicitly for The second case from @klinquist looks like a bug to me. |
We have a lot of existing code that uses module B or a variation of it, we would have to rewrite all the code to directly set on Not sure how sublime text 3 handles this but it can understand all of the different module patterns, I am guessing it is just doing some kind of text search. I stumbled upon https://marketplace.visualstudio.com/items?itemName=jrieken.fuzzy-definitions but it doesn't work as well as ST3 go to definition. The below also works btw,
So an alias kind of works but the alias object has to be created as an object literal. |
@klinquist can you open a separate issue in the TypeScript repo? |
I use a similar module pattern in an application I'm working on, and the lack of IntelliSense 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"]
}
} |
Closing as a duplicate of microsoft/TypeScript#10868 on the TypeScript team. We cannot fix this on the VSCode side, but are coordinating with the TypeScript team to prioritize IntelliSense for properties that are dynamically added to objects. |
@mjbvz thanks for the update. I will keep an eye on the other issue. |
It's very annoying, I'll hope that TypeScript team fix this quickly :) |
@barisusakli Fuzzy Definitions made the trick for me, for now at least. Sadly it still doesn't work if I want to search a function definition from an HTML file. For example, Hope someone is working on this ! |
Steps to Reproduce:
Sample module A
Sample module B
Full repo that reproduces issue https://github.com/barisusakli/vs-code-intellisense-test.
It seems like it only works if you set properties directly on
exports
.The text was updated successfully, but these errors were encountered: