You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 number
Diff line number
Diff line change
@@ -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
+
namespaceTypeOnly {
134
+
exporttypeA=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
+
namespaceA {
143
+
exportlet 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,
0 commit comments