Skip to content

Commit

Permalink
Merge pull request #861 from microsoft/jsx_ref_updates
Browse files Browse the repository at this point in the history
Improve the JSX docs
  • Loading branch information
Orta Therox authored Aug 6, 2020
2 parents 1c029ce + 450ae96 commit b0335ef
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 8 deletions.
56 changes: 55 additions & 1 deletion packages/tsconfig-reference/copy/en/options/jsx.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,60 @@ oneline: "Control how JSX is emitted"
Controls how JSX constructs are emitted in JavaScript files.
This only affects output of JS files that started in `.tsx` files.

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

<!-- This is blocked on https://github.com/microsoft/TypeScript-Website/issues/860
### For example
This sample code:
```ts
export const helloWorld = () => <h1>Hello world</h1>;
```
Default: ("react")
```tsx twoslash
declare module JSX {
interface Element {}
interface IntrinsicElements {
[s: string]: any;
}
}
// @showEmit
// @noErrors
export const helloWorld = () => <h1>Hello world</h1>;
```
Preserve:
```ts twoslash
declare module JSX {
interface Element {}
interface IntrinsicElements {
[s: string]: any;
}
}
// @showEmit
// @noErrors
// @jsx: preserve
export const helloWorld = () => <h1>Hello world</h1>;
```
React Native:
````ts twoslash
declare module JSX {
interface Element {}
interface IntrinsicElements {
[s: string]: any;
}
}
// @showEmit
// @noErrors
// @jsx: react-native
export const helloWorld = () => <h1>Hello world</h1>;
````
2 changes: 1 addition & 1 deletion packages/tsconfig-reference/scripts/tsconfigRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const defaultsForOptions = {
inlineSourceMap: "false",
inlineSources: "false",
isolatedModules: "false",
jsx: '`"preserve"`',
jsx: '`"react"`',
jsxFactory: "`React.createElement`",
keyofStringsOnly: "false",
listEmittedFiles: "false",
Expand Down
4 changes: 3 additions & 1 deletion packages/typescriptlang-org/src/redirects/setupRedirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export const setupRedirects = (
const fromArray = Object.keys(obj)
fromArray.forEach(from => {
const to = obj[from]
console.log(`Making redirect from ${from} to ${to}`)
if (process.env.CI) {
console.log(`Making redirect from ${from} to ${to}`)
}
createRedirect({
isPermanent: true,
redirectInBrowser: true,
Expand Down
5 changes: 0 additions & 5 deletions packages/typescriptlang-org/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
"target": "esnext",
"module": "commonjs",
"lib": ["dom", "es2017"],
// "allowJs": true,
// "checkJs": true,
"jsx": "react",
"strict": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmit": true,
"skipLibCheck": true,
"noImplicitAny": false,
Expand Down

0 comments on commit b0335ef

Please sign in to comment.