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 888d2ac

Browse filesBrowse files
marco-ippolitotargos
authored andcommitted
doc: specificy support for erasable ts syntax
PR-URL: #56916 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent d698cb5 commit 888d2ac
Copy full SHA for 888d2ac

File tree

Expand file treeCollapse file tree

1 file changed

+25
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-4
lines changed
Open diff view settings
Collapse file

‎doc/api/typescript.md‎

Copy file name to clipboardExpand all lines: doc/api/typescript.md
+25-4Lines changed: 25 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ added: v22.6.0
5757
5858
The flag [`--no-experimental-strip-types`][] prevents Node.js from running TypeScript
5959
files. By default Node.js will execute only files that contain no
60-
TypeScript features that require transformation, such as enums or namespaces.
60+
TypeScript features that require transformation, such as enums.
6161
Node.js will replace inline type annotations with whitespace,
6262
and no type checking is performed.
6363
To enable the transformation of such features
@@ -119,10 +119,30 @@ unless the flag [`--experimental-transform-types`][] is passed.
119119

120120
The most prominent features that require transformation are:
121121

122-
* `Enum`
123-
* `namespaces`
124-
* `legacy module`
122+
* `Enum` declarations
123+
* `namespace` with runtime code
124+
* legacy `module` with runtime code
125125
* parameter properties
126+
* import aliases
127+
128+
`namespaces` and `module` that do not contain runtime code are supported.
129+
This example will work correctly:
130+
131+
```ts
132+
// This namespace is exporting a type
133+
namespace TypeOnly {
134+
export type A = string;
135+
}
136+
```
137+
138+
This will result in [`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`][] error:
139+
140+
```ts
141+
// This namespace is exporting a value
142+
namespace A {
143+
export let x = 1
144+
}
145+
```
126146

127147
Since Decorators are currently a [TC39 Stage 3 proposal](https://github.com/tc39/proposal-decorators)
128148
and will soon be supported by the JavaScript engine,
@@ -184,6 +204,7 @@ with `#`.
184204
[CommonJS]: modules.md
185205
[ES Modules]: esm.md
186206
[Full TypeScript support]: #full-typescript-support
207+
[`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`]: errors.md#err_unsupported_typescript_syntax
187208
[`--experimental-transform-types`]: cli.md#--experimental-transform-types
188209
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
189210
[`tsconfig` "paths"]: https://www.typescriptlang.org/tsconfig/#paths

0 commit comments

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