@@ -57,7 +57,7 @@ added: v22.6.0
|
57 | 57 | |
58 | 58 | The flag [`--no-experimental-strip-types`][] prevents Node.js from running TypeScript |
59 | 59 | 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. |
61 | 61 | Node.js will replace inline type annotations with whitespace, |
62 | 62 | and no type checking is performed. |
63 | 63 | To enable the transformation of such features |
@@ -119,10 +119,30 @@ unless the flag [`--experimental-transform-types`][] is passed.
|
119 | 119 | |
120 | 120 | The most prominent features that require transformation are: |
121 | 121 | |
122 | | -* `Enum` |
123 | | -* `namespaces` |
124 | | -* `legacy module` |
| 122 | +* `Enum` declarations |
| 123 | +* `namespace` with runtime code |
| 124 | +* legacy `module` with runtime code |
125 | 125 | * 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 | +``` |
126 | 146 | |
127 | 147 | Since Decorators are currently a [TC39 Stage 3 proposal](https://github.com/tc39/proposal-decorators) |
128 | 148 | and will soon be supported by the JavaScript engine, |
@@ -184,6 +204,7 @@ with `#`.
|
184 | 204 | [CommonJS]: modules.md |
185 | 205 | [ES Modules]: esm.md |
186 | 206 | [Full TypeScript support]: #full-typescript-support |
| 207 | +[`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`]: errors.md#err_unsupported_typescript_syntax |
187 | 208 | [`--experimental-transform-types`]: cli.md#--experimental-transform-types |
188 | 209 | [`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types |
189 | 210 | [`tsconfig` "paths"]: https://www.typescriptlang.org/tsconfig/#paths |
|