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

TypeScript

TypeScript was created in 2012 by Anders Hejlsberg with the intention to implement the future standard of ECMAScript 6 but also to provide a superset of syntax and features that were not part of the specification.

There are many features in TypeScript that are a superset to the ECMAScript 6 standard, including, but not limited to the following:

  • Optional static typing with type annotations
  • Interfaces
  • Enum types
  • Generics

It's important to understand that all of the features that TypeScript provides as a superset are optional. You can write pure ECMAScript 6 and not take advantage of the additional features that TypeScript provides. The TypeScript compiler will still transcompile pure ECMAScript 6 code to ECMAScript 5 without any errors.

Most of the features that are seen in TypeScript are actually already present in other languages, such as Java and C#. One goal of TypeScript was to provide language features that support workflows and better maintainability for large-scale applications.

The problem with any nonstandard language is that nobody can tell how long the language will be maintained and how fast the momentum of the language will be in the future. In terms of support, the chances are high that TypeScript, with its sponsor, Microsoft, will actually have a long life. However, there's still no guarantee that the momentum and trend of the language will keep moving at a reasonable pace. This problem does obviously not exist for standard ECMAScript 6 because it's what the web of the future is made of and what browsers will speak natively.

Still, there are valid reasons to use the extended features of TypeScript if you'd want to address the following concerns that clearly outweigh the negative implications of an uncertain future in your project:

  • Large applications that undergo a huge amount of changes and refactoring
  • Large teams that require a strict governance while working on code
  • Creation of type-based documentation which would otherwise be difficult to maintain

Today's version of Angular is purely based on TypeScript and therefore it's your best option if you're starting to use Angular as your framework. There are also ways to use Angular with pure ECMAScript even without using a transpiler, however, you'll be missing some great language features and support.

Within this book, we're using TypeScript for all examples as well as to create our task management system. Most of the features we're going to be using have already been or will be explained to you within this chapter. The typing system of TypeScript is pretty self-explanatory, however, if you'd like to know more about TypeScript and its features, I highly recommend that you visit the TypeScript documentation on their official website: https://www.typescriptlang.org.
主站蜘蛛池模板: 丰顺县| 乌兰察布市| 将乐县| 安达市| 花莲市| 太和县| 孙吴县| 防城港市| 宣化县| 田阳县| 台中市| 金溪县| 尼勒克县| 响水县| 阜南县| 桃江县| 芒康县| 德化县| 襄城县| 淮滨县| 金堂县| 同仁县| 阜南县| 北票市| 安图县| 元氏县| 新河县| 邢台市| 太保市| 花莲市| 丽江市| 长丰县| 玉环县| 江达县| 平阴县| 曲阜市| 新干县| 海盐县| 新乐市| 五华县| 长子县|