- Error
- Reported by the type checker
TS6142
Module '{0}' was resolved to '{1}', but '--jsx' is not set.
A `.tsx` or `.jsx` module is imported but the `jsx` compiler option isn't set. Set `jsx` in tsconfig.json.
What it means
An import resolved to a file that contains JSX, but the project has no jsx option, so it doesn't know how to treat that file. It's reported on the import's module specifier. In projects with many components this often appears together with TS17004.
Example
import { Button } from "./button";
export const b = Button;
export function Button() {
return null;
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(1,24): error TS6142: Module './button' was resolved to 'button.tsx', but '--jsx' is not set.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Set
"jsx"in tsconfig.json:"react-jsx"for React 17 and later,"preserve"if another tool transforms JSX.