Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the JSX docs #861

Merged
merged 1 commit into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
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