官术网_书友最值得收藏!

The Benefits of TypeScript

TypeScript enables you to write JavaScript code. It includes static typing and other features that are very common in object-oriented languages. In addition, with TypeScript, you can use all of the features of ECMAScript 6, because the compiler converts them into readable code for the current browser.

One of the features of TypeScript is that users can create typed variables, like it is done in Java or C# (for example, const VARIABLE_NAME: Type = Value), Not only that, but TypeScript helps us to write clean, well-organized code. That is one of the reasons why the Angular team adopted TypeScript for the current version of the framework.

Before we begin, let's look at what the official TypeScript documentation states:

"TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
Any browser. Any host."

In this chapter, we will install TypeScript in our environment globally, in order to understand what happens with TypeScript files when they are converted to JavaScript. Don't worry; Angular applications already provide us with a TypeScript compiler, built into the Angular CLI.

In this chapter, we will cover the following points:

  • Installing TypeScript
  • The benefits of using TypeScript
  • How to transpile a TypeScript file to a JavaScript file
  • Writing JavaScript code with static typing
  • Understanding interfaces, classes, and generics in TypeScript
主站蜘蛛池模板: 沁水县| 酒泉市| 富阳市| 西和县| 凤翔县| 五指山市| 德庆县| 额尔古纳市| 获嘉县| 清徐县| 桃园市| 龙口市| 阿克苏市| 太康县| 唐山市| 洛宁县| 台前县| 天水市| 徐州市| 万盛区| 大埔区| 泰州市| 广东省| 萨迦县| 哈巴河县| 射阳县| 丰县| 柳河县| 宜阳县| 宿州市| 炉霍县| 秭归县| 湛江市| 公主岭市| 太仆寺旗| 徐水县| 永吉县| 弥渡县| 上犹县| 永安市| 石台县|