TypeScript error

TS17004: JSX without a jsx setting

  • Error TS17004
  • Tested with TypeScript 5.9

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

CodeTS17004
MessageCannot use JSX unless the '--jsx' flag is provided.
TypeScript's categoryerror
Listed underClasses, 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

Greeting.jsx Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: Greeting.jsx(4,10): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. Greeting.jsx(4,10): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. Greeting.jsx(4,10): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. checked 21 October 2026
/** @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.
}
JSX in a .jsx file with no jsx setting.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.jsx", "*.d.ts"]
}

What causes it

  • jsx is not set in jsconfig.json.
  • The file has JSX (.jsx, or JSX in a .js file).

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.

Greeting.jsx TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
/** @param {{ name: string }} props */
export function Greeting({ name }) {
  return <p className="greeting">Hello, {name}</p>;
}
jsx set to preserve: the checker reads JSX and leaves it for the bundler.
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-jsx and no React types, the checker reports that react/jsx-runtime cannot be found (TS2875), which means installing @types/react (or the framework's own types).
  • include must match .jsx files; ["src/**/*.js"] leaves them unchecked.

Sources

Last reviewed 20 October 2026.