Skip to content

Commit

Permalink
Update apps/site/pages/en/learn/typescript/introduction.md
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Muenzenmeyer <[email protected]>
Signed-off-by: Augustin Mauroy <[email protected]>
  • Loading branch information
AugustinMauroy and bmuenzenmeyer authored Sep 14, 2024
1 parent 5b831b7 commit acf8153
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apps/site/pages/en/learn/typescript/introduction.md
Original file line number Diff line number Diff line change
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 would not comply with declared types, TypeScript would inform 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.

## How to run TypeScript code

Expand Down

0 comments on commit acf8153

Please sign in to comment.