TypeScript Compiler Options
jsxImportSource — TypeScript compiler option
Selects the package prefix for automatic JSX runtime imports. The package must supply appropriate declarations and runtime functions. This fixture is a tiny local implementation, not React. Default in 5.8.3: react. Create the labeled files in an isolated project and run tsc -p tsconfig.json. Expected stdout: 'auto:tag'. Expected emitted files: dist/main.js. Local project fixture, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "jsxImportSource": "demo-jsx" }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| jsxImportSource | 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-jsx", "jsxImportSource": "demo-jsx" }, "files": [ "main.tsx" ]}// File: main.tsxexport {};console.log(<tag />);// File: node_modules/demo-jsx/package.json{"name":"demo-jsx","version":"1.0.0"}// File: node_modules/demo-jsx/jsx-runtime.d.tsexport namespace JSX { interface IntrinsicElements { tag: {}; } }export function jsx(name: string, props: unknown): string;// File: node_modules/demo-jsx/jsx-runtime.jsexports.jsx = (name, props) => "auto:" + name;// File: node_modules/demo-jsx/jsx-dev-runtime.d.tsexport namespace JSX { interface IntrinsicElements { tag: {}; } }export function jsxDEV(name: string, props: unknown): string;// File: node_modules/demo-jsx/jsx-dev-runtime.jsexports.jsxDEV = (name, props) => "dev:" + name;