redwood icon indicating copy to clipboard operation
redwood copied to clipboard

[Bug]: TS go to definition leads to `.d.ts` files instead of implementation in Webstorm when using directory named imports

Open PeterChen1997 opened this issue 2 years ago • 10 comments

Hello, i am new to rwjs, i thinks it's awesome!!

But i found in ts mode, the go to definition will go to the d.ts as the desc in

https://github.com/redwoodjs/redwood/issues/234

image

I want to know is there any solution for this?

PeterChen1997 avatar Apr 09 '22 07:04 PeterChen1997

Hi ! Welcome ! :smiley:

I'm not familiar with this, but maybe @dac09 know something about that ?

simoncrypta avatar Apr 09 '22 23:04 simoncrypta

This problem should affect the development efficiency of TS users, looking forward to the solution

PeterChen1997 avatar Apr 10 '22 01:04 PeterChen1997

I was wondering if this was referring to the problem of Cells not being resolved (which happens in VSCode), so i quickly fired up WebStorm and can confirm that this applies to any component imported such as this:

import MyComponent from 'src/components/MyComponent'

Workaround is to point to the actual component file, and the code navigation ends up fine in the actual implementation:

import MyComponent from 'src/components/MyComponent/MyComponent'

~~Wondering if there are other IDEs that may be affected.~~ Seems to happen in any IDE.

Philzen avatar Jul 01 '22 11:07 Philzen

@dac09 / @PeterChen1997 i believe this issue should be renamed back to something such as "[Bug] Code navigation leads to generated type in Webstorm using short import" or "[Bug] Short import paths break code navigation in IDE other than VSCode"

Navigating to a Cells implementation is a different challenge on it's own that doesn't work in any IDE so far as we know of – this issue was specifically opened about the DX in Webstorm.

Philzen avatar Jul 02 '22 13:07 Philzen

@dac09 / @PeterChen1997 / @simoncrypta / anybody with power to do so – kindly change back the title to s.th. like `[Bug] "Go to defintion..." navigates to types instead of implementation when using short import path in Webstorm" so it doesn't get mistaken as duplicate of #5862 (which affects all IDEs).

Philzen avatar Jul 07 '22 13:07 Philzen

I just rechecked in VSCode and i don't know if it's just me, but it seems to transpire this is an IDE-independent issue:

:heavy_check_mark: Using: import MyComponent from 'src/components/MyComponent/MyComponent':
CRTL+click on <MyComponent /> navigates straight to the implementation

:x: Using import MyComponent from 'src/components/MyComponent':
CRTL+click on <MyComponent /> navigates back to the import statement, CTRL+click on 'src/components/MyComponent' goes to .redwood/types/mirror/web/src/components/MyComponent/index.d.ts


@dac09 have a check yourself. Apologies for the kerfuffle, but it seems to make sense change the issue title and remove ~~in Webstorm~~ as this affects any IDE.

Not sure if there's an easy fix available though, if at all, or if we'll just have to file that under "known issues / limitations". Personally (given this is not fixable), i'd prefer not to have directory named exports available in the first place and be required to use the full import path, so i never accidentally end up in the type definition.

Philzen avatar Jul 10 '22 17:07 Philzen

Hey @PeterChen1997 and @Philzen, I just merged in #9269 which for me fixed the go-to-definition behaviour in VSCode. Can anyone of you try this out in Webstorm? I'm not confident I'm proficient enough that that IDE to confirm or deny that fix applies to this issue too. You should be able to test this out with the latest canary version to confirm yarn rw upgrade -t canary (once it's published in about 30 mins).

Josh-Walker-GM avatar Oct 10 '23 19:10 Josh-Walker-GM

Hi @Josh-Walker-GM, I can confirm that Webstorm is still with the same behaviour, opening the .d.ts file, I tested using RedwodJS 6.4.0 in both, Webstorm and VSCode. Only in VSCode this is fixed.

MarcioBarrientos avatar Nov 17 '23 11:11 MarcioBarrientos

Thank you @MarcioBarrientos! We'll leave this issue open until we can find a fix for it in Webstorm too

Josh-Walker-GM avatar Nov 17 '23 13:11 Josh-Walker-GM

Definitely also an issue for PhpStorm 2023.3.5

Lucsy3012 avatar Mar 22 '24 13:03 Lucsy3012