Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions packages/tsconfig-reference/copy/en/options/jsx.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ oneline: "Specify what JSX code is generated."
Controls how JSX constructs are emitted in JavaScript files.
This only affects output of JS files that started in `.tsx` files.

- `react`: Emit `.js` files with JSX changed to the equivalent `React.createElement` calls
- `react-jsx`: Emit `.js` files with the JSX changed to `_jsx` calls
- `react-jsxdev`: Emit `.js` files with the JSX changed to `_jsx` calls
- `react-jsx`: Emit `.js` files with the JSX changed to `_jsx` calls for production
- `react-jsxdev`: Emit `.js` files with the JSX changed to `_jsx` calls for development
- `preserve`: Emit `.jsx` files with the JSX unchanged
- `react-native`: Emit `.js` files with the JSX unchanged
- `react`: Emit `.js` files with JSX changed to the equivalent `React.createElement` calls

### For example

Expand All @@ -20,7 +20,7 @@ This sample code:
export const HelloWorld = () => <h1>Hello world</h1>;
```

Default: `"react"`
default: `"react-jsx"`<sup>[[1]](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)</sup>

```tsx twoslash
declare module JSX {
Expand All @@ -31,10 +31,11 @@ declare module JSX {
}
// @showEmit
// @noErrors
// @jsx: react-jsx
export const HelloWorld = () => <h1>Hello world</h1>;
```

Preserve: `"preserve"`
React dev transform: `"react-jsxdev"`<sup>[[1]](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)</sup>

```tsx twoslash
declare module JSX {
Expand All @@ -45,11 +46,11 @@ declare module JSX {
}
// @showEmit
// @noErrors
// @jsx: preserve
// @jsx: react-jsxdev
export const HelloWorld = () => <h1>Hello world</h1>;
```

React Native: `"react-native"`
Preserve: `"preserve"`

```tsx twoslash
declare module JSX {
Expand All @@ -60,11 +61,11 @@ declare module JSX {
}
// @showEmit
// @noErrors
// @jsx: react-native
// @jsx: preserve
export const HelloWorld = () => <h1>Hello world</h1>;
```

React 17 transform: `"react-jsx"`<sup>[[1]](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)</sup>
React Native: `"react-native"`

```tsx twoslash
declare module JSX {
Expand All @@ -75,11 +76,12 @@ declare module JSX {
}
// @showEmit
// @noErrors
// @jsx: react-jsx
// @jsx: react-native
export const HelloWorld = () => <h1>Hello world</h1>;
```

React 17 dev transform: `"react-jsxdev"`<sup>[[1]](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)</sup>

Legacy runtime: `"react"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure this is language we want to use.


```tsx twoslash
declare module JSX {
Expand All @@ -90,6 +92,5 @@ declare module JSX {
}
// @showEmit
// @noErrors
// @jsx: react-jsxdev
export const HelloWorld = () => <h1>Hello world</h1>;
```
```