You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/10-basics/20-typescript-as-a-second-language/en/README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ You should also have an understanding of data types, variables, conditional cons
5
5
6
6
Learning a second programming language is easier than learning a first one, so the structure of the material changes a lot. Here we review the basic constructs to quickly familiarize ourselves with the syntax. Then we move on to the tasks for which TypeScript is studied.
7
7
8
-
In this tutorial, we'll learn what TypeScript is, as well as break down its features, installation, and getting it up and running.
8
+
In this tutorial, we'll learn what TypeScript is, as well as break down its features, installation, and getting it up and running.
9
9
10
10
## What is TypeScript
11
11
@@ -57,18 +57,18 @@ sum(10n, 5);
57
57
58
58
Not only will the code above fail to run, but it will also fail to compile. The TypeScript compiler will stop execution and indicate a type mismatch error.
59
59
60
-
If we look at the function definition, we can see that we are facing almost the same JavaScript, except for the type description of input variables in the function.
60
+
If we look at the function definition, we can see that we are facing almost the same JavaScript, except for the type description of input variables in the function.
61
61
It says that parameters `a` and `b` have type `number`. The rest of the TypeScript code is annotated with types in much the same way. The type descriptions can be very complex in places, but the idea remains the same.
62
62
63
-
We cannot say unequivocally which approach is better - static or dynamic typing. It all depends on the specific situation, and successful projects can be written in different languages. Since we are studying TypeScript in this
63
+
We cannot say unequivocally which approach is better - static or dynamic typing. It all depends on the specific situation, and successful projects can be written in different languages. Since we are studying TypeScript in this
64
64
course, we will look at the peculiarities of working with it.
65
65
66
66
## TypeScript Features
67
67
68
68
TypeScript has become one of the most popular typed languages due to the following features:
69
69
70
-
* TypeScript is almost completely compatible with JavaScript in terms of features and types. Everything written in
71
-
TypeScript is also available in JavaScript, and vice versa. TypeScript is called a superset of the JavaScript
70
+
* TypeScript is almost completely compatible with JavaScript in terms of features and types. Everything written in
71
+
TypeScript is also available in JavaScript, and vice versa. TypeScript is called a superset of the JavaScript
72
72
language. Meaning that it is the same JavaScript + type description.
73
73
* The TypeScript compiler turns TypeScript code into JavaScript code. That is, it removes type definitions from TypeScript code. This process is also known as **transpilation**.
74
74
* The developer of TypeScript is Microsoft
@@ -80,7 +80,7 @@ Let's look at the last feature in more detail.
80
80
81
81
Strong typing is not related to static typing. It refers to the extent to which a language allows automatic type conversions. A static language can be weak, and vice versa.
82
82
83
-
For example, in JavaScript we can add a number to a string. When the language encounters such a construct, it will automatically perform a type conversion: `10 + 'one'`.
83
+
For example, in JavaScript we can add a number to a string. When the language encounters such a construct, it will automatically perform a type conversion: `10 + 'one'`.
84
84
TypeScript won't do that. It will generate an error: `The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type`.
85
85
86
86
Many dynamic languages are strongly typed. For example, Ruby and Python are among them. Strong typing only makes the language better and does not complicate the process of programming.
@@ -121,4 +121,4 @@ In this lesson, we learned about the TypeScript language. We learned that it is
121
121
122
122
It is impossible to say which language is better. It all depends on the specific task and features of the language.
123
123
124
-
We also learned about the features of TypeScript in this lesson, and we also learned how to install and run it.
124
+
We also learned about the features of TypeScript in this lesson, and we also learned how to install and run it.
Copy file name to clipboardExpand all lines: modules/25-types/25-literal-types/ru/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
2
2
В программировании встречаются ситуации, когда мы работаем с ограниченным набором значений какого-то типа, например, с определенными строками. В них могут входить справочные данные, статусы и так далее. Как мог бы выглядеть статус заказа:
Copy file name to clipboardExpand all lines: modules/50-objects/45-record/en/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ The `Key` key will accept all values from `K` by brute force. In turn, `K` is a
13
13
14
14
This kind of construction, where we do not additionally define any specific fields with dynamic keys, is quite common. The built-in Utility Types provide a ready solution for this - `Record<Keys, Type>`. This generalized type takes a key type as its first argument and a value type as its second. Inside, everything is organized similarly as in our `Context` type:
Подобная конструкция, когда мы не задаем дополнительно никаких специфичных полей с динамическими ключами, встречается довольно часто. Встроенные Utility Types предоставляют для этого готовое решение — `Record<Keys, Type>`. Этот обобщенный тип принимает первым аргументом тип ключа, а вторым — тип значения. Внутри все устроено схожим образом, как в нашем типе `Context`:
0 commit comments