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: apps/site/pages/en/learn/typescript/run-natively.md
+11-6
Original file line number
Diff line number
Diff line change
@@ -12,24 +12,29 @@ In the previous articles, we learned how to run TypeScript code using transpilat
12
12
13
13
## Running TypeScript code with Node.js
14
14
15
-
Since V22.6.0, Node.js has experimental support for some TypeScript syntax. You can write code that's valid TypeScript directly in Node.js without the need to transpile it first.
15
+
Since V22.6.0, Node.js has experimental support for some TypeScript syntax via "type stripping". You can write code that's valid TypeScript directly in Node.js without the need to transpile it first.
16
16
17
-
So how do you run TypeScript code with Node.js?
17
+
The `--experimental-strip-types` flag tells Node.js to strip the type annotations from the TypeScript code before running it.
18
18
19
19
```bash
20
20
node --experimental-strip-types example.ts
21
21
```
22
22
23
-
The `--experimental-strip-types` flag tells Node.js to strip the type annotations from the TypeScript code before running it.
24
-
25
23
And that's it! You can now run TypeScript code directly in Node.js without the need to transpile it first, and use TypeScript to catch type-related errors.
24
+
25
+
In V22.7.0 this experimental support was extended to transform TypeScript-only syntax, like `enum`s and `namespace`, with the addition of the `--experimental-transform-types` flag.
Future versions of Node.js will include support for TypeScript without the need for a command line flag.
27
32
28
33
## Limitations
29
34
30
-
At the time of writing, the experimental support for TypeScript in Node.js has some limitations. To allow TypeScript to run in node.js, our collaborators have chosen to only strip types from the code.
35
+
At the time of writing, the experimental support for TypeScript in Node.js has some limitations.
31
36
32
-
You can get more information on the [API docs](https://nodejs.org/docs/latest/api/typescript.html#unsupported-typescript-features)
37
+
You can get more information on the [API docs](https://nodejs.org/docs/latest/api/typescript.html#typescript-features).
0 commit comments