I’ve even somehow gotten TypeScript to work in some of my apps. But it’s always been difficult, and I find myself hacking my way through it rather than following repeatable steps.
Unfortunately, I’m still seeing the same problem, regardless of whether I add types: [] or run yarn workspace web add @types/jest and add "types": ["jest"].
nvm current says v14.15.4.
I’m on Windows running Ubuntu via WSL 1, if that matters.
That’s useful information, thanks for sharing. I’m on windows myself, but not WSL.
If you’re still getting
ReferenceError: HomePage is not defined
And it’s from the router, then you’re probably hitting the issue @vinaypugal mentioned. If you switch your pages over to .js, and try making some other file .tsx instead – does that work?
@Tobbe Yes! I just tried creating and using a .ts file other than a page, and it worked.
It sounds like you’re saying pages can be .tsx on Linux or Windows but apparently not WSL 1.
I spent hours last night trying to upgrade to WSL 2 but still haven’t been successful. Do you happen to know if everything would work for me if I were on WSL 2?
The router still doesn’t have TS support. So you can’t write your pages using typescript. I think everything else should work. And it looks like the router is getting TS support in the next release, so you won’t have to wait long for it to work for you.
It’s the automatic import (with code splitting) that the router does that doesn’t find your .ts or .tsx files.
If you want to get it to work today you can manually import your tsx pages in the router with a relative path all the way in to the page and it should work.
The behavior should be the same on WSL1 as on all other setups.