error TS17004: Cannot use JSX unless the '--jsx' flag is provided. is reported on each JSX element when the config has no jsx setting. The checker can read JSX, but only once it is told how the JSX will be turned into JavaScript.
For a JavaScript project with a bundler, the bundler does that work, so the usual value is "preserve", which checks the JSX and leaves it alone, or "react-jsx" for React's automatic runtime. When no JSX types are loaded either, each element is also reported as TS7026.
At a glance
| Code | TS17004 |
|---|---|
| Message | Cannot use JSX unless the '--jsx' flag is provided. |
| TypeScript's category | error |
| Listed under | Classes, JSX and unused code |
| Turned off by | jsx |
| In .js files | Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file |
The message is TypeScript's own text from its diagnostic messages file (Apache-2.0).
What it looks like
/** @param {{ name: string }} props */
export function Greeting({ name }) {
return <p className="greeting">Hello, {name}</p>;error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.jsx", "*.d.ts"]
} What causes it
jsxis not set injsconfig.json.- The file has JSX (
.jsx, or JSX in a.jsfile).
How to fix it
Set jsx
Add "jsx": "preserve" (the bundler transforms JSX) or "react-jsx" (React's automatic runtime; it needs React's types installed). The jsx page lists the values and what each one expects.
/** @param {{ name: string }} props */
export function Greeting({ name }) {
return <p className="greeting">Hello, {name}</p>;
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": [],
"jsx": "preserve"
},
"include": ["*.jsx", "*.d.ts"]
} Gotchas
- With
react-jsxand no React types, the checker reports thatreact/jsx-runtimecannot be found (TS2875), which means installing@types/react(or the framework's own types). includemust match.jsxfiles;["src/**/*.js"]leaves them unchecked.
Sources
- JSX · TypeScript handbook
- TSConfig Reference: jsx · TypeScript
- diagnosticMessages.json (TypeScript 5.9.3) · TypeScript on GitHub
Last reviewed 20 October 2026.