How To Transform JSX using TypeScript

TypeScript can transform JSX templates. You need use the .tsx extension and set the --jsx flag to React.

tsc --jsx React ./src/App.tsx

For a library like Preact or Mithril you need to addtionally use the --jsxFactory command-line parameter:

tsc --jsx React --jsxFactory h ./src/App.tsx

Subscribe to My Newsletter

The latest programming-related news, articles and resources - sent to your inbox monthly. Unsubscribe anytime.