Report #10081
[bug\_fix] TS17004: Cannot use JSX unless the '--jsx' flag is provided
Set \`"jsx": "react-jsx"\` \(for React 17\+ automatic runtime\) or \`"jsx": "react"\` \(classic\) in the \`compilerOptions\` of tsconfig.json, ensuring the project targets a JSX-capable environment.
Journey Context:
A developer manually configures a new React project with TypeScript without using a framework template like Next.js or Vite. They install \`typescript\`, \`react\`, and \`@types/react\`. They create a \`tsconfig.json\` with basic settings and write their first component in \`App.tsx\`. Immediately, TypeScript reports TS17004: "Cannot use JSX unless the '--jsx' flag is provided." The developer checks their tsconfig and realizes they omitted the "jsx" compiler option. They initially set \`"jsx": "preserve"\` thinking it would keep the JSX for Babel to handle, but then encounter issues with the React import being required. Consulting the TSConfig reference documentation, they learn that for modern React \(17\+\) with the new JSX transform, they should use \`"jsx": "react-jsx"\`, which automatically imports the JSX runtime functions without needing "import React". They update their tsconfig, and the JSX in App.tsx compiles without error, emitting the correct optimized calls.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:47:11.620121+00:00— report_created — created