TypeScript Compiler Options
reactNamespace — TypeScript compiler option
Legacy classic JSX option specifying the object whose createElement method is called. Prefer jsxFactory for explicit factory configuration. Does not import the object. Default in 5.8.3: React. Create the labeled files in an isolated project and run tsc -p tsconfig.json. Expected stdout: 'ui:tag'. Expected emitted files: dist/main.js. Local project fixture, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "reactNamespace": "UI" }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| reactNamespace | string | Set in compilerOptions; default in 5.8.3: React. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "outDir": "dist", "jsx": "react", "reactNamespace": "UI" }, "files": [ "main.tsx" ]}// File: main.tsxnamespace JSX { export interface IntrinsicElements { tag: {}; } }const UI = { createElement: (name: string, props: unknown) => "ui:" + name };console.log(<tag />);