Skip to content

Commit

Permalink
Update from feedback
Browse files Browse the repository at this point in the history
Co-Authored-By: Brian Muenzenmeyer <[email protected]>
  • Loading branch information
AugustinMauroy and bmuenzenmeyer committed Sep 14, 2024
1 parent 461bbd5 commit 43f5c59
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions apps/site/pages/en/learn/typescript/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ authors: sbielenica, ovflowd, vaishnav-mk, AugustinMauroy

## What is TypeScript

**[TypeScript](https://www.typescriptlang.org)** is an open-source language maintained and developed by Microsoft. It's loved and used by a lot of software developers around the world.
**[TypeScript](https://www.typescriptlang.org)** is an open-source language maintained and developed by Microsoft.

Basically, TypeScript add adds additional syntax to JavaScript to support a tighter integration with your editor. Catch errors early in your editor or in your CI/CD pipeline, and write more maintainable code.
Basically, TypeScript adds additional syntax to JavaScript to support a tighter integration with your editor. Catch errors early in your editor or in your CI/CD pipeline, and write more maintainable code.

We can talk about other TypeScript benefits later, let's see some examples now!

Expand Down Expand Up @@ -42,7 +42,7 @@ const isJustineAnAdult = isAdult(justine);

The first part (with the `type` keyword) is responsible for declaring our custom object type representing users. Later we utilize this newly created type to create function `isAdult` that accepts one argument of type `User` and returns `boolean`. After this, we create `justine`, our example data that can be used for calling the previously defined function. Finally, we create a new variable with information on whether `justine` is an adult.

There are additional things about this example that you should know. Firstly, if we would not comply with declared types, TypeScript would alarm us that something is wrong and prevent misuse. Secondly, not everything must be typed explicitly - TypeScript is very smart and can infer types for us. For example, variable `isJustineAnAdult` is of type `boolean` even if we didn't type it explicitly or `justine` would be valid argument for our function even though we didn't declare this variable as of `User` type.
There are additional things about this example that you should know. Firstly, if we do not comply with the declared types, TypeScript will inform us that something is wrong and prevent misuse. Secondly, not everything must be typed explicitlyTypeScript infers types for us. For example, the variable `isJustineAnAdult` is of type `boolean` even if we didn't type it explicitly, and `justine` would be a valid argument for our function even though we didn't declare this variable as of `User` type.

## How to run TypeScript code

Expand Down
12 changes: 6 additions & 6 deletions apps/site/pages/en/learn/typescript/run-natively.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ layout: learn
authors: AugustinMauroy
---

> **⚠️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 on future versions of Node.js.
> **⚠️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

Expand All @@ -14,22 +14,22 @@ In the previous articles, we learned how to run TypeScript code using transpilat

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.

So how do you run typed JavaScript code with Node.js?
So how do you run TypeScript code with Node.js?

```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 typed JavaScript code directly in Node.js without the need to transpile it first, and use TypeScript to catch type-related errors.
In the future we all hope that this feature will be stable and available in the LTS version of Node.js, so that we can all enjoy it without any additional steps.
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.
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. To allow TypeScript to run in node.js, our collaborators have chosen to only strip types from the code.

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#unsupported-typescript-features)

## Important notes

Expand Down
4 changes: 2 additions & 2 deletions apps/site/pages/en/learn/typescript/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In the previous article, we learned how to run TypeScript code using transpilati

## Running TypeScript code with `ts-node`

[ts-node](https://typestrong.org/ts-node/) is a TypeScript execution environment for node.js. It allows you to run TypeScript code directly in node.js without the need to compile it first. But it's not typechecking your code. So we recommend to type check your code first with `tsc` and then run it with `ts-node` before shipping it.
[ts-node](https://typestrong.org/ts-node/) is a TypeScript execution environment for Node.js. It allows you to run TypeScript code directly in Node.js without the need to compile it first. Note, however, that it does not type check your code. So we recommend to type check your code first with `tsc` and then run it with `ts-node` before shipping it.

To use `ts-node`, you need to install it first:

Expand All @@ -26,7 +26,7 @@ npx ts-node example.ts

## Running TypeScript code with `tsx`

[tsx](https://tsx.is/) is another TypeScript execution environment for node.js. It allows you to run TypeScript code directly in node.js without the need to compile it first. But it's not typechecking your code. So we recommend to type check your code first with `tsc` and then run it with `tsx` before shipping it.
[tsx](https://tsx.is/) is another TypeScript execution environment for Node.js. It allows you to run TypeScript code directly in Node.js without the need to compile it first. Note, however, that it does not type check your code. So we recommend to type check your code first with `tsc` and then run it with `tsx` before shipping it.

To use `tsx`, you need to install it first:

Expand Down

0 comments on commit 43f5c59

Please sign in to comment.