docs/jsx/others.md
TypeScript provides you with the ability to use something other than React with JSX in a type safe manner. The following lists the customizability points, but note that this is for advanced UI framework authors:
react style emit by using "jsx" : "preserve" option. This means that JSX is emitted as is and then you can use your own custom transpiler to transpile the JSX portions.JSX global module:
JSX.IntrinsicElements interface members.class must be inherited by components by customizing the default interface ElementClass extends React.Component<any, any> { } declaration.props) by customizing the declare module JSX { interface ElementAttributesProperty { props: {}; } } declaration.jsxFactoryPassing --jsxFactory <JSX factory Name> along with --jsx react allows for using a different JSX factory from the default React.
The new factory name will be used to call createElement functions.
import {jsxFactory} from "jsxFactory";
var div = <div>Hello JSX!</div>
Compiled with:
tsc --jsx react --reactNamespace jsxFactory --m commonJS
Results in:
"use strict";
var jsxFactory_1 = require("jsxFactory");
var div = jsxFactory_1.jsxFactory.createElement("div", null, "Hello JSX!");
jsx pragmaYou can even specify a different jsxFactory per file using jsxPragma e.g.
/** @jsx jsxFactory */
import {jsxFactory} from "jsxFactory";
var div = <div>Hello JSX!</div>
With --jsx react this file will emit to use the factory specfied in the jsx pragma:
"use strict";
var jsxFactory_1 = require("jsxFactory");
var div = jsxFactory_1.jsxFactory.createElement("div", null, "Hello JSX!");