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?

3 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

Please sign in to leave a comment.