Specify the JSX factory function to use when targeting 'react' JSX emit, e.g....
Production Risk
Build will fail; resolve before shipping.
A compiler configuration error (TS6146): Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'.. This diagnostic is emitted by the TypeScript compiler when specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'..
- 1JSX syntax used without enabling '--jsx' compiler option
- 2Missing React or JSX runtime import
TypeScript compiler reports TS6146 during type checking.
// Triggers TS6146 // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'.
expected output
error TS6146: Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'.
Fix
Enable JSX in tsconfig.json
WHEN Using JSX syntax in TypeScript files
// tsconfig.json
{
"compilerOptions": {
"jsx": "react-jsx" // or "react", "preserve", etc.
}
}Why this works
The '--jsx' option tells TypeScript how to transform JSX; choose 'react-jsx' for React 17+ or 'react' for older versions.
TypeScript Compiler Diagnostics
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev