Skip to content

Commit 215a5c7

Browse files
content(learn): update from feedback
Co-Authored-By: Antoine du Hamel <[email protected]>
1 parent dfe4e40 commit 215a5c7

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

apps/site/pages/en/learn/typescript/introduction.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ function isAdult(user: User): boolean {
3232
return user.age >= 18;
3333
}
3434

35-
const justine: User = {
35+
const justine = {
3636
name: 'Justine',
3737
age: 23,
38-
};
38+
} satisfies User;
3939

40-
const isJustineAnAdult: boolean = isAdult(justine);
40+
const isJustineAnAdult = isAdult(justine);
4141
```
4242

4343
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.
4444

45-
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 deduce types for us. For example, variable `isJustineAnAdult` would be of type `boolean` even if we didn't type it explicitly or `justine` would be valid argument for our function even if we didn't declare this variable as of `User` type.
45+
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.
4646

4747
## How to run TypeScript code
4848

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ In the previous articles, we learned how to run TypeScript code using transpilat
1212

1313
## Running TypeScript code with Node.js
1414

15-
Node.js has experimental support for TypeScript. You can run TypeScript code directly in Node.js without the need to compile it first.
15+
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.
1616

17-
So how do you run TypeScript code with Node.js?
17+
So how do you run typed JavaScript code with Node.js?
1818

1919
First, you need to install a nightly version of Node.js. You can download it from the [official Node.js website](https://nodejs.org/download/nightly/).
2020

21-
Then, you can run your TypeScript code like this:
21+
Then, you can run your file like this:
2222

2323
```bash
2424
node --experimental-strip-types example.ts
2525
```
2626

2727
The `--experimental-strip-types` flag tells Node.js to strip the type annotations from the TypeScript code before running it.
2828

29-
And that's it! You can now run TypeScript code directly in Node.js without the need to compile it first.
29+
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.
3030
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.
3131

3232
## Limitations
@@ -57,4 +57,4 @@ converting newer JavaScript syntax into older standards.
5757

5858
Thanks to all the contributors who have made this feature possible. We hope that this feature will be stable and available in the LTS version of Node.js soon.
5959

60-
We can understand that this feature is experimental and has some limitations, and this may disappoint you. So please be patient and wait for the stable version of this feature. And **NEVER** spam us. If you are happy, you can share these articles on social media and tell your friends about this feature.
60+
We can understand that this feature is experimental and has some limitations; if that doesn't suit your usecase, please use something else, or contribute a fix. Bug reports are also welcome, please keep in mind the project is run by volunteers, without warranty of any kind, so please be patient if you can't contribute the fix yourself.

apps/site/pages/en/learn/typescript/transpile.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ const justine: User = {
3636
const isJustineAnAdult: boolean = isAdult(justine);
3737
```
3838

39-
**Step 2:** Install TypeScript globally using npm:
39+
**Step 2:** Install TypeScript globally using a package manager:
4040

41-
If you want to discover npm, you can check our [our introduction to the npm package manager](/learn/getting-started/an-introduction-to-the-npm-package-manager)
41+
In this example we're going to use npm, you can check our [our introduction to the npm package manager](/learn/getting-started/an-introduction-to-the-npm-package-manager) for more information.
4242

43-
There are two ways to install TypeScript, globally or locally. We recommend installing it globally for the sake of simplicity.
43+
There are two ways to install TypeScript, globally or locally. We do not recommend installing it globally for the sake of everyone working with you.
4444

4545
```bash displayName="Install TypeScript globally"
4646
npm i -g typescript # -g is a shorthand for --global

0 commit comments

Comments
 (0)