The most notable unique feature is the aforementioned strong typing, which is also the origin of the name TypeScript. TypeScript variables are associated with types such as strings, numbers, and booleans, which tell the compiler what kind of data they can store. TypeScript also supports type inference, catch-all any
Includes types, that is, types that do not require the programmer to explicitly assign the type of the variable.
TypeScript, unlike JavaScript, was designed for object-oriented programming. Concepts such as inheritance and access control that are unintuitive in JavaScript can be easily implemented in TypeScript. Additionally, TypeScript allows you to implement interfaces, a concept that has little meaning in JavaScript.
However, any function that can be coded in TypeScript can also be coded in JavaScript. This is because TypeScript’s compilation method is not compilation in the general sense (for example, C++ is compiled into a binary executable file that can run on specified hardware). Instead, the TypeScript compiler transpiles TypeScript code into JavaScript. You can see the differences in Daniel Monesh’s article on the Toptal blog comparing the functionally identical TypeScript and JavaScript.
Transpiled JavaScript can run anywhere JavaScript code can be executed, from a web browser to a server with Node.js installed. Of course, one question comes to mind here. If TypeScript is ultimately just a way to generate JavaScript code, why bother using it? To answer this question, we need to look at where TypeScript comes from and what it is used for.
A brief history of TypeScript
TypeScript was developed internally at Microsoft and released as open source in 2012. Microsoft still serves as the project manager and main developer. Article from ZDnet, 2012According to , “TypeScript emerged from the experience of several teams at Microsoft attempting to develop and maintain Microsoft products using JavaScript.”
At the time, Microsoft was trying to build Bing Maps as a competitor to Google Maps and offer a web version of its office suite, and JavaScript was the primary development language for this task. But the task was easier said than done. Although JavaScript has spread into a huge number of niche fields, it was originally developed for interactive web design, and its main advantage is the ability to quickly and easily write working JavaScript code. But in enterprise software development, the requirements were different. Robustness and ease of maintenance are more important than speed.
Source: www.itworld.co.kr