TS17004: Cannot use JSX unless the jsx flag is provided - in CI
A file contains JSX but the tsconfig does not enable JSX compilation.
What this error means
Type-checking fails with TS17004 at the first JSX element because the jsx option is unset.
tsc
src/App.tsx(4,10): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.Common causes
How to fix it
Set the jsx option
- Use react-jsx for the modern automatic runtime, or react for classic
tsconfig.json
{
"compilerOptions": { "jsx": "react-jsx" }
}Use the .tsx extension
- Rename files containing JSX to .tsx
shell
mv src/App.ts src/App.tsxHow to prevent it
- Set jsx in tsconfig and keep JSX in .tsx files so CI compiles components.
Frequently asked questions
What causes "TS17004 JSX not enabled"?
Type-checking fails with TS17004 at the first JSX element because the jsx option is unset.
How do I fix TS17004 JSX not enabled?
Set the jsx option
Related guides
TS1128: Declaration or statement expected - in CIFix "error TS1128: Declaration or statement expected" when tsc runs in CI - a stray token, an extra brace, or…
TS1005: ';' expected (or other token) - in CIFix "error TS1005: ';' expected" (and other "X expected" variants) when tsc runs in CI - a syntax error or a…
TS2307: Cannot find module - in CIFix "error TS2307: Cannot find module 'x' or its corresponding type declarations" when tsc runs in CI - a mis…