> For the complete documentation index, see [llms.txt](https://typescript-jp.gitbook.io/deep-dive/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://typescript-jp.gitbook.io/deep-dive/tsx/others.md).

# React以外のJSX

TypeScriptは、React with JSX以外のものをタイプセーフな方法で使用する機能を提供します。以下は、カスタマイズ可能なポイントを示していますが、これは高度なUIフレームワークの作成者向けです。

* `"jsx" : "preserve"`オプションを使って`react`形式の出力を無効にすることができます。これは、JSXが\_そのままの状態で\_出力されることを意味します。そして、あなた自身のカスタムトランスパイラを使用してJSX部分をトランスパイルすることができます
* `JSX`グローバルモジュールを使う：
  * `JSX.IntrinsicElements`インターフェースのメンバをカスタマイズすることで、どのHTMLタグが利用可能で、どのように型チェックされるかを制御することができます。
  * コンポーネントを使用する場合：
    * デフォルトの`interface ElementClass extends React.Component<any, any> { }`宣言をカスタマイズすることによって、どのクラスがコンポーネントによって継承されなければならないかを制御できます
    * どのプロパティが属性(デフォルトは`props`)の型チェックに使われるかを制御できます。`declare module JSX { interface ElementAttributesProperty { props: {}; } }`の宣言をカスタマイズすることで行います。

## `jsxFactory`

`--jsxFactory <JSX factory Name>`と `--jsx react`を一緒に渡すことで、デフォルトの`React`とは別のJSXファクトリを使うことができます。

新しいファクトリ名は`createElement`関数を呼び出すために使われます。

### 例

```typescript
import {jsxFactory} from "jsxFactory";

var div = <div>Hello JSX!</div>
```

コンパイル：

```
tsc --jsx react --reactNamespace jsxFactory --m commonJS
```

結果：

```javascript
"use strict";
var jsxFactory_1 = require("jsxFactory");
var div = jsxFactory_1.jsxFactory.createElement("div", null, "Hello JSX!");
```

## `jsx`プラグマ(`jsx` pragma)

`jsxPragma`を使用してファイルごとに異なる`jsxFactory`を指定することもできます。

```javascript
/** @jsx jsxFactory */
import {jsxFactory} from "jsxFactory";

var div = <div>Hello JSX!</div>
```

`--jsx react`を指定すると、このファイルはjsxプラグマで指定されたファクトリを使用して出力されます：

```javascript
"use strict";
var jsxFactory_1 = require("jsxFactory");
var div = jsxFactory_1.jsxFactory.createElement("div", null, "Hello JSX!");
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://typescript-jp.gitbook.io/deep-dive/tsx/others.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
