TypeScript Compiler Options
jsxFragmentFactory — TypeScript compiler option
Selects the classic fragment value. When customizing the element factory, configure a compatible fragment factory; it must exist at runtime. Default in 5.8.3: React.Fragment. Create the labeled files in an isolated project and run tsc -p tsconfig.json. Expected stdout: 'fragment:tag'. Expected emitted files: dist/main.js. Local project fixture, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "jsxFragmentFactory": "Frag" }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| jsxFragmentFactory | string | Set in compilerOptions; default in 5.8.3: React.Fragment. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "outDir": "dist", "jsx": "react", "jsxFactory": "h", "jsxFragmentFactory": "Frag" }, "files": [ "main.tsx" ]}// File: main.tsxnamespace JSX { export interface IntrinsicElements { tag: {}; } }const Frag = "fragment";function h(name: string, props: unknown, ...children: unknown[]) { return [name, ...children].join(":"); }console.log(<><tag /></>);