TS18034
TypeScriptERRORNotableTypeHIGH confidence

Specify the JSX fragment factory function to use when targeting 'react' JSX e...

Production Risk

Build will fail; resolve before shipping.

What this means

A TypeScript diagnostic (TS18034): Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'.. This diagnostic is emitted by the TypeScript compiler when specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'..

Why it happens
  1. 1JSX syntax used without enabling '--jsx' compiler option
  2. 2Missing React or JSX runtime import
How to reproduce

TypeScript compiler reports TS18034 during type checking.

trigger — this will error
trigger — this will error
// Triggers TS18034
// Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'.

expected output

error TS18034: Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'.

Fix

Enable JSX in tsconfig.json

WHEN Using JSX syntax in TypeScript files

Enable JSX in tsconfig.json
// tsconfig.json
{
  "compilerOptions": {
    "jsx": "react-jsx"  // or "react", "preserve", etc.
  }
}

Why this works

The '--jsx' option tells TypeScript how to transform JSX; choose 'react-jsx' for React 17+ or 'react' for older versions.

Sources
Official documentation ↗

TypeScript Compiler Diagnostics

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All TypeScript errors