← Go Back

React + TypeScript with Parcel

Broken Post?Let me know

Photo by Kira auf der Heide on Unsplash

Learned today that it's easy to create React + TypeScript site with Parcel without using CRA (create-react-app).

Parcel Documentation has a whole (short but complete) section on how to use TypeScript file with Parcel.


Just include TypeScript file (either .ts or .tsx for React components) in an HTML file, and Parcel will know what to do with it.

<title>MobX React TypeScript</title>
<div id="app"></div>
<script src="../src/index.tsx"></script>
view raw index.html hosted with ❤ by GitHub

View this gist on GitHub

including TypeScript file

One caveat is that you need to set a jsx option in tsconfig.json to react for it to work.

"compilerOptions": {
"jsx": "react"
view raw tsconfig.js hosted with ❤ by GitHub

View this gist on GitHub

jsx option in tsconfig.json



Loading counts...

❤️ 0 💬 0
Fetching Replies...
There is no reply...