Say that in my TypeScript project, I use Express and a method like this:
response.send('Hello');
I want to look how the send()
method is implemented. However, when I ctrl+click the method name in WebStorm, it takes me to a .d.ts
file (TypeScript definitions) instead of the real source. Understandably but a bit unpleasantly. What's the easiest way to get to the source?
Navigate to a file with the Navigation bar Use the Navigation bar as a handy tool to find your way across the project. Press Alt+Home to activate the Navigation bar. Use the arrow keys or the mouse pointer to locate the desired file.
With WebStorm, you can run and debug client-side TypeScript code and TypeScript code running in Node. js. Learn more from Running and debugging TypeScript.
The easiest way to get to the source is disabling the corresponding library (if d.ts
files were downloaded as a library)/removing typescript definitions from project. Then WebStorm will try to find the definition in .js files.
There is a feature request for a possibility to 'merge' TypeScript definitions with available .js
definitions, using d.ts
for completion and .js
- for navigation (WEB-12630). The only problem here is that WebStorm can't always find the correct definition in .js
- and that's the reason for using TypeScript definitions instead. For example, if the module properties are defined by iterating files in file system:
fs.readdirSync(__dirname + '/middleware').forEach(function(filename){
if (!/\.js$/.test(filename)) return;
var name = basename(filename, '.js');
function load(){ return require('./middleware/' + name); }
exports.middleware.__defineGetter__(name, load);
exports.__defineGetter__(name, load);
});
Resolving them for completion/navigation doesn't seem to be possible
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With