Skip to content

Commit 3a75e84

Browse files
marco-ippolitoRafaelGSS
authored andcommitted
doc: specificy support for erasable ts syntax
PR-URL: #56916 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Pietro Marchini <[email protected]>
1 parent ef216de commit 3a75e84

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

doc/api/typescript.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ added: v22.6.0
5656
5757
The flag [`--experimental-strip-types`][] enables Node.js to run TypeScript
5858
files. By default Node.js will execute only files that contain no
59-
TypeScript features that require transformation, such as enums or namespaces.
59+
TypeScript features that require transformation, such as enums.
6060
Node.js will replace inline type annotations with whitespace,
6161
and no type checking is performed.
6262
To enable the transformation of such features
@@ -123,10 +123,30 @@ unless the flag [`--experimental-transform-types`][] is passed.
123123

124124
The most prominent features that require transformation are:
125125

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

131151
Since Decorators are currently a [TC39 Stage 3 proposal](https://github.com/tc39/proposal-decorators)
132152
and will soon be supported by the JavaScript engine,
@@ -188,6 +208,7 @@ with `#`.
188208
[CommonJS]: modules.md
189209
[ES Modules]: esm.md
190210
[Full TypeScript support]: #full-typescript-support
211+
[`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`]: errors.md#err_unsupported_typescript_syntax
191212
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
192213
[`--experimental-transform-types`]: cli.md#--experimental-transform-types
193214
[`tsconfig` "paths"]: https://www.typescriptlang.org/tsconfig/#paths

0 commit comments

Comments
 (0)