2019-01-22

React + TypeScript with Parcel

programming, quicktip, react, selfnote

banner

_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.

https://parceljs.org/typeScript.html

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

https://gist.github.com/dance2die/18a5d6e192c3bab736b79f8abd437f7d

including TypeScript file

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

https://gist.github.com/dance2die/d3e4b01bbf49c09c82103be4137d31f2

jsx option in tsconfig.json

Resources