- Due to the interpretability of the language, you can find out about the error only after executing the code;
- The complexity of using the practices of object-oriented programming;
- Dynamic typing.
To solve such problems, a programming language was created
The development of TypeScript began at the end of 2012. Although it originated in the company Microsoft, and its actual creator is the programmer
Strong typing is one of the options for working with data types, which means that the following conditions are met:
- The data object always has a strictly defined type;
- A variable can only be assigned strictly the same data type as the variable;
- Operations require parameters of strictly defined types;
- Implicit type conversion is not allowed.
SyntaxError: Unexpected token (1:8) 1 : return () ^
fruit can be either a string, a number, or a function. No error occurs. In a strongly typed language, such code will fail compilation.
: string before
fruit means that the variable is assigned the type
string (string). In the next line, we assign a number to it, which is not allowed.
TypeScript checks the code for errors during compilation, which will obviously speed up the identification of such troubles.
TypeScript implements many of the concepts that are inherent in object-oriented languages, such as inheritance, polymorphism, encapsulation and access modifiers, and so on.
TypeScript is being developed as an OpenSource project and, like many projects, is hosted on github. In addition, it is cross-platform, which means that we can use both Windows and MasOS or Linux for development.
Especially if you need to use some library or framework that is not ported to TS. In this case, developers will have to independently describe the signatures (indicate data types) of all functions and methods - a rather lengthy process, given the size of modern libraries.
Also, the threshold for entering TypeScript is higher - in order to take advantage of its benefits, it is important to know data types and object-oriented programming.
Now that you know what TypeScript is, I'll try to tell you when you need to and in which you shouldn't use it.
My reasoning is very simple: TypeScript should always be used if you know that the project will grow and need to be maintained. Should I translate already written projects? - I cannot give you an exact answer, usually in such projects it is difficult to find time for refactoring, and even more so for switching to TypeScript. However, it is still worth thinking about it, because you get typing and the ability to use modern standards.
Now we are ready to learn TypeScript with you, but in order to understand how much you learned this lesson, take the test in the mobile application в нашей школы по этой теме.
Thanks goes to these wonderful people (emoji key):