"[ts] Unterminated regular expression literal."

So my case was a bit unique. I had the same error message. but everything got fix after I restarted the build process (e.g. in this case I was working with storybook, so npm run storybook). The symptom was that, even I changed my file name to be .tsx the error still reporting the same file as .ts. That reminded me that I changed the file name when the build is already watching and running. That's when I decided restart the build command and wolaa! everything fixed itself.

Sometime its just that --- "Have you turn it off and on again?"


Just in case someone else runs across this and has named their file appropriately, re-inspect your regex to make sure you haven't accidentally created an invalid regex. For example, mine looked like:

/^https?:\/\/

and it should have been:

/^https?:\/\//
             ^ left this lil' guy off

You can also use an online regex tool to make sure you've created a valid regex.


It turns out I was using the .ts file extension instead of .tsx

Make sure your component file extension is .tsx (if you're using Typescript) or .jsx (if you're using Javascript).