I cannot get the squiggly line (“has no default export”) in vs code to disappear from my newly generated cell.
I new to Redwood, building a small app for editing of some hierarchical structures, probably using mantine-react-table as the gui component.
I anticipate different pages that will have slightly different views and/or editing methods on the data, and I think that means I will have different cells against the same Prisma model.
To generate a new cell, I used
yarn rw g cell DriverGridCell --list
(the Prisma model is
Driver
). I can update the generated cell so that it references the existing model, and everything seems to work fine. Still, my editor complains
Module '"xxxxxx/web/src/components/DriverGridsCell/DriverGridsCell"' has no default export.ts(1192)
when importing to the page.
When I look at some of the other autogenerated cells, there is also no default export, but no error. What is different is that vscode finds the code in the
.redwood
folder, where there is something that has a default export…
So, there is some magic here that I don’t understand, and a squiggly line I can’t get rid of.
Any pointers?
Hey
@ahjulstad
,
Your problem should go away if you change the import from
'web/src/components/DriverGridsCell/DriverGridsCell'
to
'web/src/components/DriverGridsCell'
VSCode’s auto import picks the first one annoyingly, which causes this behaviour. Running
rw g types
is usually a good idea too
To answer your question in the title though, the default export in Cells comes from Redwood’s build tooling. We generate the default export for you
To get TS to not complain, we generate types (you’ll see them in
.redwood/types/mirror
- this is where the actual TS definitions of the Cells are located.
(also headsup, we
finally
have a fix for cmd+click on Cells too
fix(types): Generate maps to allow improved "go to definition" behaviour by Josh-Walker-GM · Pull Request #9269 · redwoodjs/redwood · GitHub
)