Go to declaration takes you to type declaration

Hi,

Apologies if this is a stupid question or specific to my config, but I’ve always had an issue with my project where cmd + clicking through to cells or the routes file takes me to the type declaration (in .redwood) rather than the actual component file.

Other components are fine so perhaps it’s something to do with the special nature of cells and the routes file (and perhaps some other files as well).

If I specifically ask to go to the type declaration, it simply scrolls to the import for the specific component at the top of the current file.

I’m using WebStorm if that helps.

Hi @cattre, welcome back to the RW forums!

Totally valid question, and it definitely isn’t something odd in your setup.

Unfortunately this behaviour is due to the way we do “directory named modules” i.e. the fact that you can import Cells without needing an index.js e.g.

web/src/components/RecipeCell
├── RecipeCell.mock.ts
├── RecipeCell.stories.tsx
├── RecipeCell.test.tsx
└── RecipeCell.tsx

Notice that there isn’t a index.tsx in there, but you can still import like this:

import { RecipeCell } from 'src/components/RecipeCell'

but also the fact that Success, Loading, Error components are automatically generated for you. The routes are largely the same, as we generate the types based on your path string.

This is unfortunate tradeoff we’ve had to make, where the framework takes care of all of the plumbing for you keeping your code focused vs syntax that plays better with the TS compiler.


We would be very open to any suggestions to fix/improve this behaviour!