Hacker News new | ask | show | jobs
by mssundaram 2025 days ago
How do I use this for Typescript and TSX? I see a few mentions of Typescript in the code (e.g. a transform plugin) but no guidance on how to set it up
1 comments

It's built-in, just change the file extension to `.tsx` or create a new file with that extension.
I tried renaming public/index.js to public/index.tsx and get "./public/index.js - File not found" in the build watcher. Of course the index.html is still referencing the index.js file - what do I need to do?

Edit: It does work for e.g. pages/about/index.js to rename to index.tsx - so maybe it's just the main index that won't work as Typescript?

Also it looks like there is no default definition provided for imported CSS modules - the import resolves to a string so "styles.about" doesn't compile

You need to change the HTML to point to the tsx file too:

<script type="module" src="./index.tsx"></script>

There are ambient TS definitions for CSS Modules, it just had a bug in 1.0.0 - fix is merged and will be released shortly.

Thank you!