diff --git a/apps/site/pages/en/learn/typescript/run-natively.md b/apps/site/pages/en/learn/typescript/run-natively.md index 6a101ad176012..e16a1bf38c85b 100644 --- a/apps/site/pages/en/learn/typescript/run-natively.md +++ b/apps/site/pages/en/learn/typescript/run-natively.md @@ -12,24 +12,29 @@ In the previous articles, we learned how to run TypeScript code using transpilat ## Running TypeScript code with Node.js -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. +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. -So how do you run TypeScript code with Node.js? +The `--experimental-strip-types` flag tells Node.js to strip the type annotations from the TypeScript code before running it. ```bash node --experimental-strip-types example.ts ``` -The `--experimental-strip-types` flag tells Node.js to strip the type annotations from the TypeScript code before running it. - 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. + +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. + +```bash +node --experimental-strip-types --experimental-transform-types another-example.ts +``` + Future versions of Node.js will include support for TypeScript without the need for a command line flag. ## Limitations -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. +At the time of writing, the experimental support for TypeScript in Node.js has some limitations. -You can get more information on the [API docs](https://nodejs.org/docs/latest/api/typescript.html#unsupported-typescript-features) +You can get more information on the [API docs](https://nodejs.org/docs/latest/api/typescript.html#typescript-features). ## Important notes