TypeScript Compiler Options

jsxFactory — TypeScript compiler option

Changes the classic element factory and can affect JSX namespace lookup. The configured factory must exist at runtime; this is not an automatic runtime setting. Default in 5.8.3: React.createElement. Create the labeled files in an isolated project and run tsc -p tsconfig.json. Expected stdout: 'TAG'. Expected emitted files: dist/main.js. Local project fixture, not a single-file editor.

Formal Syntax & Structure

typescript syntaxtypescript
{  "compilerOptions": {    "jsxFactory": "h"  }}

Parameters & Attributes

NameTypeDescription
jsxFactorystringSet in compilerOptions; default in 5.8.3: React.createElement.

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"  },  "files": [    "main.tsx"  ]}// File: main.tsxnamespace JSX { export interface IntrinsicElements { tag: {}; } }function h(name: string, props: unknown) { return name.toUpperCase(); }console.log(<tag />);
TypeScript Reference