Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PeterChen1997 opened this issue Apr 9, 2022 · 10 comments
Labels
bug/confirmed We have confirmed this is a bug topic/typescript

Comments

@PeterChen1997
Copy link
Contributor

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

#234

image

I want to know is there any solution for this?

@PeterChen1997 PeterChen1997 changed the title go to definition error in webstorm Typescript - go to definition error in webstorm Apr 9, 2022
@simoncrypta
Copy link
Collaborator

simoncrypta commented Apr 9, 2022

Hi ! Welcome ! 😃

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

@PeterChen1997
Copy link
Contributor Author

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

@Philzen
Copy link
Contributor

Philzen commented Jul 1, 2022

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 dac09 changed the title Typescript - go to definition error in webstorm [Bug]: TypeScript go to definition points to generated types for Cells Jul 1, 2022
@dac09 dac09 added the bug/confirmed We have confirmed this is a bug label Jul 1, 2022
@Philzen
Copy link
Contributor

Philzen commented Jul 2, 2022

@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
Copy link
Contributor

Philzen commented Jul 7, 2022

@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).

@dac09 dac09 changed the title [Bug]: TypeScript go to definition points to generated types for Cells [Bug]: TS go to definition leads to .d.ts files instead of implementation in Webstorm when using directory named imports Jul 7, 2022
@Philzen
Copy link
Contributor

Philzen commented Jul 10, 2022

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:

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

❌ 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.

@Josh-Walker-GM
Copy link
Collaborator

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).

@MarcioBarrientos
Copy link

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.

@Josh-Walker-GM
Copy link
Collaborator

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

@Lucsy3012
Copy link

Definitely also an issue for PhpStorm 2023.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/confirmed We have confirmed this is a bug topic/typescript
Projects
Status: Backlog
Development

No branches or pull requests

7 participants