From 249f87e6417bad7b9df73adcdbaee826e1135b1e Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Sun, 2 Feb 2025 15:32:15 +0100 Subject: [PATCH 1/2] feat(learn): organise TypeScript articles from simplest to advanced usage --- apps/site/navigation.json | 12 ++++++------ apps/site/pages/en/learn/typescript/run-natively.md | 6 ++---- apps/site/pages/en/learn/typescript/run.md | 2 +- apps/site/pages/en/learn/typescript/transpile.md | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/site/navigation.json b/apps/site/navigation.json index 850e6899a0681..f417399f9d780 100644 --- a/apps/site/navigation.json +++ b/apps/site/navigation.json @@ -198,17 +198,17 @@ "link": "/learn/typescript/introduction", "label": "components.navigation.learn.typescript.links.introduction" }, - "transpile": { - "link": "/learn/typescript/transpile", - "label": "components.navigation.learn.typescript.links.transpile" + "runNatively": { + "link": "/learn/typescript/run-natively", + "label": "components.navigation.learn.typescript.links.runNatively" }, "run": { "link": "/learn/typescript/run", "label": "components.navigation.learn.typescript.links.run" }, - "runNatively": { - "link": "/learn/typescript/run-natively", - "label": "components.navigation.learn.typescript.links.runNatively" + "transpile": { + "link": "/learn/typescript/transpile", + "label": "components.navigation.learn.typescript.links.transpile" } } }, diff --git a/apps/site/pages/en/learn/typescript/run-natively.md b/apps/site/pages/en/learn/typescript/run-natively.md index 773f0201077d0..f1da8de175753 100644 --- a/apps/site/pages/en/learn/typescript/run-natively.md +++ b/apps/site/pages/en/learn/typescript/run-natively.md @@ -4,11 +4,9 @@ layout: learn authors: AugustinMauroy, khaosdoctor, jakebailey, robpalme --- -> **⚠️WARNING⚠️:** All content in this article uses Node.js experimental features. Please make sure you are using a version of Node.js that supports the features mentioned in this article. And remember that experimental features can change in future versions of Node.js. - # Running TypeScript Natively -In the previous articles, we learned how to run TypeScript code using transpilation and with a runner. In this article, we will learn how to run TypeScript code using Node.js itself. +Since v23.6.0, Node.js enables "type stripping" by default. If you are using v23.6.0 or later and your source code contains only [erasable typescript syntax](https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option), you do not need this article. ## Running TypeScript code with Node.js @@ -28,7 +26,7 @@ In V22.7.0 this experimental support was extended to transform TypeScript-only s node --experimental-transform-types another-example.ts ``` -From V23 onwards, the `--experimental-strip-types` flag is enabled by default (you can disable it via the [`--no-experimental-strip-types`](https://nodejs.org/docs/latest-v23.x/api/cli.html#--no-experimental-strip-types) flag), enabling you to run any supported syntax, so running files like the one below with `node file.ts` is supported: +From v23.6.0 onwards, type stripping is enabled by default (you can disable it via [`--no-experimental-strip-types`](https://nodejs.org/docs/latest-v23.x/api/cli.html#--no-experimental-strip-types)), enabling you to run any supported syntax, so running files like the one below with `node file.ts` is supported: ```ts function foo(bar: number): string { diff --git a/apps/site/pages/en/learn/typescript/run.md b/apps/site/pages/en/learn/typescript/run.md index b3404b1c45566..bd33e5cbbba20 100644 --- a/apps/site/pages/en/learn/typescript/run.md +++ b/apps/site/pages/en/learn/typescript/run.md @@ -6,7 +6,7 @@ authors: AugustinMauroy # Running TypeScript with a runner -In the previous article, we learned how to run TypeScript code using transpilation. In this article, we will learn how to run TypeScript code using a runner. +If you want more advanced processing of TypeScript than node's built-in support (or you're using node prior to v22.7.0), you have 2 options: use a runner (which handles much of the complexity for you), or handle it all yourself via [transpilation](./transpile.md). ## Running TypeScript code with `ts-node` diff --git a/apps/site/pages/en/learn/typescript/transpile.md b/apps/site/pages/en/learn/typescript/transpile.md index 62c042d4e902f..d55e7c03b13f6 100644 --- a/apps/site/pages/en/learn/typescript/transpile.md +++ b/apps/site/pages/en/learn/typescript/transpile.md @@ -6,7 +6,7 @@ authors: AugustinMauroy # Running TypeScript code using transpilation -Transpilation is the process of converting source code from one language to another. In the case of TypeScript, it's the process of converting TypeScript code to JavaScript code. This is necessary because browsers and Node.js can't run TypeScript code directly. +Transpilation is the process of converting source code from one language to another. In the case of TypeScript, it's the process of converting TypeScript code to JavaScript code. This is necessary because browsers and Node.js don't run TypeScript code directly. ## Compiling TypeScript to JavaScript From 17cc0db2a19b9d98fa51f831d818b4581c07aef3 Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Mon, 31 Mar 2025 07:23:06 -0400 Subject: [PATCH 2/2] fixup! Co-authored-by: Steven Signed-off-by: Aviv Keller --- apps/site/pages/en/learn/typescript/run.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/site/pages/en/learn/typescript/run.md b/apps/site/pages/en/learn/typescript/run.md index bd33e5cbbba20..7afa013c04927 100644 --- a/apps/site/pages/en/learn/typescript/run.md +++ b/apps/site/pages/en/learn/typescript/run.md @@ -6,7 +6,7 @@ authors: AugustinMauroy # Running TypeScript with a runner -If you want more advanced processing of TypeScript than node's built-in support (or you're using node prior to v22.7.0), you have 2 options: use a runner (which handles much of the complexity for you), or handle it all yourself via [transpilation](./transpile.md). +If you want more advanced processing of TypeScript than the built-in support (or you're using Node.js prior to v22.7.0), you have 2 options: use a runner (which handles much of the complexity for you), or handle it all yourself via [transpilation](./transpile.md). ## Running TypeScript code with `ts-node`