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.
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.
| <html> | |
| <head> | |
| <title>MobX React TypeScript</title> | |
| </head> | |
| <body> | |
| <div id="app"></div> | |
| <script src="../src/index.tsx"></script> | |
| </body> | |
| </html> |
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" | |
| ... | |
| } |
jsx option in tsconfig.json
Resources
Webmentions
Loading counts...
❤️ 0 💬 0
Fetching Replies...
There is no reply...