Skip to content

Commit dcf5f03

Browse files
authored
docs: clarify target in tsconfig.json (#18377)
1 parent 1414bfa commit dcf5f03

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/guide/features.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ But a few libraries haven't transitioned to this new default yet, including [`li
8888

8989
- [TypeScript documentation](https://www.typescriptlang.org/tsconfig#target)
9090

91-
Vite does not transpile TypeScript with the configured `target` value by default, following the same behaviour as `esbuild`.
91+
Vite ignores the `target` value in the `tsconfig.json`, following the same behavior as `esbuild`.
9292

93-
The [`esbuild.target`](/config/shared-options.html#esbuild) option can be used instead, which defaults to `esnext` for minimal transpilation. In builds, the [`build.target`](/config/build-options.html#build-target) option takes higher priority and can also be set if needed.
93+
To specify the target in dev, the [`esbuild.target`](/config/shared-options.html#esbuild) option can be used, which defaults to `esnext` for minimal transpilation. In builds, the [`build.target`](/config/build-options.html#build-target) option takes higher priority over `esbuild.target` and can also be set if needed.
9494

9595
::: warning `useDefineForClassFields`
96-
If `target` is not `ESNext` or `ES2022` or newer, or if there's no `tsconfig.json` file, `useDefineForClassFields` will default to `false` which can be problematic with the default `esbuild.target` value of `esnext`. It may transpile to [static initialization blocks](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Static_initialization_blocks#browser_compatibility) which may not be supported in your browser.
96+
97+
If `target` in `tsconfig.json` is not `ESNext` or `ES2022` or newer, or if there's no `tsconfig.json` file, `useDefineForClassFields` will default to `false` which can be problematic with the default `esbuild.target` value of `esnext`. It may transpile to [static initialization blocks](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Static_initialization_blocks#browser_compatibility) which may not be supported in your browser.
9798

9899
As such, it is recommended to set `target` to `ESNext` or `ES2022` or newer, or set `useDefineForClassFields` to `true` explicitly when configuring `tsconfig.json`.
99100
:::

0 commit comments

Comments
 (0)