Skip to content

Commit b929d9e

Browse files
agilgur5Orta Theroxorta
authored
fix: jsx is undefined by default, not preserve or react (#1102)
* fix: `jsx` is undefined by default, not preserve or react - one gets an error when using JSX without configuring `jsx`: `error TS17004: Cannot use JSX unless the '--jsx' flag is provided.` - TSConfig Reference said default was `react`, which is inaccurate - Compiler Options said default was `preserve`, which is also inaccurate - Add a `undefined` as the default in TSConfig Reference, same as allowUnrechableCode - Remove the default in Compiler Options, same as all the other options without defaults ---- History: Reference: - `preserve` was written as the default in eae5cc3#diff-444415c73770eafd0f9db7d708d74131R5 - But then was written as `react` in the body in eae5cc3#diff-444415c73770eafd0f9db7d708d74131R5 - It was then switched to `react` in 450ae96#diff-a912c6af3a16bf4288093c1264955bc6R120 - And then removed in 76b7d43#diff-a912c6af3a16bf4288093c1264955bc6L120 Compiler Options: - `preserve` was written as the default in 66f17ad#diff-bfc78b96c15b0ee906c1ab6176546dceR41 * Update Compiler Options.md * Update Compiler Options.md Co-authored-by: Orta Therox <ortam@microsoft.com> Co-authored-by: Orta Therox <git@orta.io>
1 parent 78d3b56 commit b929d9e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/documentation/copy/en/project-config/Compiler Options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Option | Type | Default
6565
`--inlineSources` | `boolean` | `false` | Emit the source alongside the sourcemaps within a single file; requires `--inlineSourceMap` or `--sourceMap` to be set.
6666
`--init` | | | Initializes a TypeScript project and creates a `tsconfig.json` file.
6767
`--isolatedModules` | `boolean` | `false` | Perform additional checks to ensure that separate compilation (such as with [`transpileModule`](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function) or [@babel/plugin-transform-typescript](https://babeljs.io/docs/en/babel-plugin-transform-typescript)) would be safe.
68-
`--jsx` | `string` | `"preserve"` | Support JSX in `.tsx` files: `"react"`, `"preserve"`, `"react-native"`. See [JSX](/docs/handbook/jsx.html).
68+
`--jsx` | `string` | | Support JSX in `.tsx` files: `"react"`, `"preserve"`, `"react-native"`. See [JSX](/docs/handbook/jsx.html).
6969
`--jsxFactory` | `string` | `"React.createElement"` | Specify the JSX factory function to use when targeting react JSX emit, e.g. `React.createElement` or `h`.
7070
`--jsxFragmentFactory` | `string` | `"React.Fragment"` | Specify the JSX fragment factory function to use when targeting react JSX emit, e.g. `Fragment`.
7171
`--keyofStringsOnly` | `boolean` | `false` | Resolve `keyof` to string valued property names only (no numbers or symbols).

packages/tsconfig-reference/scripts/tsconfigRules.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export const defaultsForOptions = {
135135
inlineSourceMap: "false",
136136
inlineSources: "false",
137137
isolatedModules: "false",
138+
jsx: "undefined",
138139
jsxFactory: "`React.createElement`",
139140
keyofStringsOnly: "false",
140141
listEmittedFiles: "false",
@@ -186,7 +187,7 @@ export const defaultsForOptions = {
186187
};
187188

188189
export const allowedValues = {
189-
jsx: ["`react` (default)", "`react-native`", "`preserve`"],
190+
jsx: ["`react`", "`react-native`", "`preserve`"],
190191
jsxFactory: ["Any identifier or dotted identifier"],
191192
lib: ["See main content"],
192193
target: [

0 commit comments

Comments
 (0)