![](https://csdnimg.cn/release/download_crawler_static/11178901/bg10.jpg)
xix
Introduction
Atwood’s Law: any application that can be written in JavaScript will eventually be written
in JavaScript.
—Jeff Atwood
TypeScript is a language created and maintained by Microsoft, and released under an open-source Apache
2.0 License (2004). The language is focused on making the development of JavaScript programs scale to
many thousands of lines of code. In fact, Microsoft has written both the Azure Management Portal (1.2
million lines of code) and the Visual Studio Code editor (300,000 lines of code) in TypeScript. The language
attacks the large-scale JavaScript programming problem by offering better design-time tooling, compile-
time checking, and dynamic module loading at runtime.
As you might expect from a language created by Microsoft, there is excellent support for TypeScript
within Visual Studio, but plenty of other development tools have also added support for the language,
including VS Code, WebStorm, Eclipse, Sublime Text, Vi, Atom, IntelliJ, and Emacs among others. The
widespread support from these tools as well as the permissive open-source license makes TypeScript a
viable option outside of the traditional Microsoft ecosystem.
The TypeScript language is a typed superset of JavaScript, which is compiled to plain JavaScript in
the flavor of your choosing. This makes programs written in TypeScript highly portable as they can run
on almost any machine — in web browsers, on web servers, and even in native applications on operating
systems that expose a JavaScript API, such as WinJS.
The language features found in TypeScript can be divided into three categories based on their
relationship to JavaScript (see Figure1). The first two sets are related to versions of the ECMA-262
ECMAScript Language Specification, which is the official specification for JavaScript. The ECMAScript 5
specification forms the basis of TypeScript and supplies the largest number of features in the language.
Subsequent versions of the ECMAScript specification are rolled into TypeScript releases, often as early
previews that feature down-level compilation to older versions of the specication. The third and final set of
language features includes items that are not planned to become part of the ECMAScript standard, such as
generics and type annotations. All the additional features of TypeScript can be output to a number of widely
supported versions of JavaScript.
TypeScript has several native frameworks, including Angular, Ionic, RxJs 5, and Dojo 2. Additionally,
because TypeScript is such a close relative of JavaScript, you can consume the myriad of existing libraries
and frameworks written in JavaScript; Aurelia, Backbone, Bootstrap, Durandal, jQuery, Knockout,
Modernizr, PhoneGap, Prototype, Raphael, React, Underscore, Vue, and many more are all usable in
TypeScript programs. Correspondingly, once your TypeScript program has been compiled it can be
consumed from any JavaScript program too.
TypeScript's similarity to JavaScript is beneficial if you already have experience with JavaScript or other
C-like languages. The similarity also aids the debugging process as the generated JavaScript correlates
closely to the original TypeScript code. Source maps can also be generated to aid debugging, with browser
developer tools displaying your TypeScript code during in-browser debugging.