TypeScript Compiler Options
jsx — TypeScript compiler option
Selects JSX transformation and output extension. preserve keeps JSX in .jsx; react-native keeps JSX in .js; react uses a classic factory; react-jsx and react-jsxdev import automatic runtime helpers. It does not install a runtime. Default in 5.8.3: unset. Create the labeled files in an isolated project and run tsc -p tsconfig.json. Expected stdout: 'tag'. Expected emitted files: dist/main.js. Local project fixture, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "jsx": "react" }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| jsx | preserve | react-native | react | react-jsx | react-jsxdev | Set in compilerOptions; default in 5.8.3: unset. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "outDir": "dist", "jsx": "react" }, "files": [ "main.tsx" ]}// File: main.tsxnamespace JSX { export interface IntrinsicElements { tag: {}; } }const React = { createElement: (name: string, props: unknown) => name };console.log(<tag />);