Skip to content

Commit 9ad96f4

Browse files
authored
content(learn): Add TypeScript transform docs (#7202)
Signed-off-by: tchetwin <[email protected]>
1 parent f5db266 commit 9ad96f4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

apps/site/pages/en/learn/typescript/run-natively.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,29 @@ In the previous articles, we learned how to run TypeScript code using transpilat
1212

1313
## Running TypeScript code with Node.js
1414

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.
1616

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.
1818

1919
```bash
2020
node --experimental-strip-types example.ts
2121
```
2222

23-
The `--experimental-strip-types` flag tells Node.js to strip the type annotations from the TypeScript code before running it.
24-
2523
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.
26+
27+
```bash
28+
node --experimental-strip-types --experimental-transform-types another-example.ts
29+
```
30+
2631
Future versions of Node.js will include support for TypeScript without the need for a command line flag.
2732

2833
## Limitations
2934

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.
3136

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).
3338

3439
## Important notes
3540

0 commit comments

Comments
 (0)