Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7353266

Browse filesBrowse files
marco-ippolitotargos
authored andcommitted
doc: improve type stripping documentation
PR-URL: #56916 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent 888d2ac commit 7353266
Copy full SHA for 7353266

File tree

Expand file treeCollapse file tree

1 file changed

+12
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-10
lines changed
Open diff view settings
Collapse file

‎doc/api/typescript.md‎

Copy file name to clipboardExpand all lines: doc/api/typescript.md
+12-10Lines changed: 12 additions & 10 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,16 @@ added: v22.6.0
5555

5656
> Stability: 1.1 - Active development
5757
58-
The flag [`--no-experimental-strip-types`][] prevents Node.js from running TypeScript
59-
files. By default Node.js will execute only files that contain no
60-
TypeScript features that require transformation, such as enums.
61-
Node.js will replace inline type annotations with whitespace,
58+
By default Node.js will execute TypeScript files that contains only
59+
erasable TypeScript syntax.
60+
Node.js will replace TypeScript syntax with whitespace,
6261
and no type checking is performed.
63-
To enable the transformation of such features
64-
use the flag [`--experimental-transform-types`][].
65-
TypeScript features that depend on settings within `tsconfig.json`,
62+
To enable the transformation of non erasable TypeScript syntax, which requires JavaScript code generation,
63+
such as `enum` declarations, parameter properties use the flag [`--experimental-transform-types`][].
64+
To disable this feature, use the flag [`--no-experimental-strip-types`][].
65+
66+
Node.js ignores `tsconfig.json` files and therefore
67+
features that depend on settings within `tsconfig.json`,
6668
such as paths or converting newer JavaScript syntax to older standards, are
6769
intentionally unsupported. To get full TypeScript support, see [Full TypeScript support][].
6870

@@ -71,7 +73,7 @@ By intentionally not supporting syntaxes that require JavaScript code
7173
generation, and by replacing inline types with whitespace, Node.js can run
7274
TypeScript code without the need for source maps.
7375

74-
Type stripping works with most versions of TypeScript
76+
Type stripping is compatible with most versions of TypeScript
7577
but we recommend version 5.7 or newer with the following `tsconfig.json` settings:
7678

7779
```json
@@ -139,7 +141,7 @@ This will result in [`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`][] error:
139141

140142
```ts
141143
// This namespace is exporting a value
142-
namespace A {
144+
namespace A {
143145
export let x = 1
144146
}
145147
```
@@ -204,9 +206,9 @@ with `#`.
204206
[CommonJS]: modules.md
205207
[ES Modules]: esm.md
206208
[Full TypeScript support]: #full-typescript-support
207-
[`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`]: errors.md#err_unsupported_typescript_syntax
208209
[`--experimental-transform-types`]: cli.md#--experimental-transform-types
209210
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
211+
[`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`]: errors.md#err_unsupported_typescript_syntax
210212
[`tsconfig` "paths"]: https://www.typescriptlang.org/tsconfig/#paths
211213
[`tsx`]: https://tsx.is/
212214
[`verbatimModuleSyntax`]: https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.