◐ Shell
clean mode source ↗

doc: specificy support for erasable ts syntax · nodejs/node@888d2ac

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