Ctrl + click to TypeScript implemenation

 

If I do Ctrl + click on a method in JavaScript file, it jumps to TypeScript implementation. Is this right?
How to I go to JavaScript implementation with Ctrl + click?

6 comments
Comment actions Permalink

Yes, it's expected - WebStorm uses the TypeScript definition files to power its code completion for standard JavaScript objects and methods.

I'm not sure what implementation you are looking for... What JavaScript library is Date() defined in?

0
Comment actions Permalink

No, I just wanted to know is it right action. Thank you for answer.

By the way, I have another question.

In the callback function of `reduce()`, `x` is accumulated to `a` and `a` is returned to `sum1`.

But WebStorm mark `a` as unused value. Why? `a` is used as return value of `reduce()` method.

0
Comment actions Permalink
(a, x) => a += x

 is not equal to

 

function (a, x) {

a += x;
return a;

}

 

it's

function (a, x) {
return a+= x;
}

 

i.e. you are implicitly returning an assignment

return a = a + x

 Inspection says that value assigned to `a` is unused, and `return a += x` can be replaced with `return a + x`. See comments in WEB-12462

Note that returning assignment is considered a bad style. ESLint reports errors on such constructions (https://eslint.org/docs/rules/no-return-assign)

1
Comment actions Permalink

Elena Pogorelova How can we customise the way the IDE (PHPStorm in my case) handles CTRL + Click interaction? As shown in the OP, CTRL + Click will currently take a user to the type definition file, which I've personally never wanted to do, and always find it incredibly frustrating when ending up on a type definition file, and not the actual source file.

Here's another simple example:

When I CTRL + Click on the Messages.scss import, I get taken to the type definition for it.. I want to go to the source file instead..

I've tried playing around with Keymaps in settings:

  • Go To Declaration or Usages - This is the default behaviour, so takes me to the type definition file
  • Go To Implementation(s) - This also takes me to the type definition file
  • Go To Type Declaration - This does nothing, and this is the one that I would expect to be taking to the type definition file

How can we fix this issue?

0
Comment actions Permalink

There's a related issue on that: https://youtrack.jetbrains.com/issue/WEB-27982. Please vote for it to raise its priority and be notified of updates

0
Comment actions Permalink

Thanks Elena Pogorelova.. It appears that ticket was created 4 years ago, I don't think my casting a vote for it is going to do much :/.

In any event, when CTRL + Clicking on an imported node_module, I always get take to the `.d.ts` file rather than the source file, and trying all the different "Go To" things as mentioned previously doesn't help, I'm always taken to the Typescript definition file.. Can we customise/change this behaviour so we can actually get to source files without having to manually search for it?

0

Please sign in to leave a comment.