React + TypeScript with Parcel

programming, quicktip, react, selfnote


title: React + TypeScript with Parcel date: "2019-01-22" banner: ./images/featured-image.jpg published_at: "2019-01-23T03:46:32.000Z" tags: "programming, quicktip, react, selfnote" author: Sung M. Kim

_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

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

jsx option in tsconfig.json