redwood
redwood copied to clipboard
[Bug]: TS go to definition leads to `.d.ts` files instead of implementation in Webstorm when using directory named imports
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

I want to know is there any solution for this?
Hi ! Welcome ! :smiley:
I'm not familiar with this, but maybe @dac09 know something about that ?
This problem should affect the development efficiency of TS users, looking forward to the solution
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.
@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.
@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).
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.
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).
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.
Thank you @MarcioBarrientos! We'll leave this issue open until we can find a fix for it in Webstorm too
Definitely also an issue for PhpStorm 2023.3.5