13

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?

1
  • Were you able to find any solution to that? Commented May 9, 2023 at 16:20

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.