TypeScript is an open-source programming language developed and maintained by Microsoft. This is a very strict JavaScript superset, and adds optional static typing to the language.
TypeScript is designed for large and transpile application development to JavaScript. Since TypeScript is a JavaScript superset, existing JavaScript programs are also valid TypeScript programs. TypeScript can be used to develop JavaScript applications for client-side and server-side (Node.js) executions.
TypeScript supports a definition file that can contain existing JavaScript type library information, such as a C header file that can describe the existing object file structure. This allows other programs to use the values ââdefined in the file as if they are statically typed TypeScript entities. There are third-party header files for popular libraries like jQuery, MongoDB, and D3.js. The TypeScript header for the basic Node.js modules is also available, enabling the development of Node.js programs in TypeScript.
The TypeScript compiler itself is written in TypeScript and compiled into JavaScript. It is licensed under the Apache License 2.
TypeScript is included as a first-class programming language in Microsoft Visual Studio 2013 Update 2 and later, in addition to C # and other Microsoft languages. The official extension allows Visual Studio 2012 to support TypeScript as well.
Anders Hejlsberg, principal architect of C # and creator of Delphi and Turbo Pascal, has worked in TypeScript development.
Video TypeScript
History
TypeScript was first published in October 2012 (in version 0.8), after two years of internal development at Microsoft. Immediately after the announcement, Miguel de Icaza praised the language itself, but criticized the lack of mature IDE support aside from Microsoft Visual Studio, which was not available on Linux and OS X at the time. In 2013 there is support in other IDEs, especially in Eclipse, through plug-ins donated by Palantir Technologies. Various text editors, including Emacs, Vim, Sublime, Webstorm, Atom and Microsoft Visual Studio Code themselves also support TypeScript.
TypeScript 0.9, released in 2013, adds support for generics. TypeScript 1.0 was released at Microsoft Build developer conference in 2014. Visual Studio 2013 Update 2 provides built-in support for TypeScript.
In July 2014, the developer team announced a new TypeScript compiler, claiming a performance gain of 5ÃÆ'â ⬠". At the same time, the source code, originally hosted on CodePlex, was transferred to GitHub.
On September 22, 2016, TypeScript 2.0 was released; it introduced several features, including the ability for programmers to optionally prevent variables from being assigned Maps TypeScript
Design language
TypeScript comes from the perceived lack of JavaScript for large-scale application development both at Microsoft and among their external customers. Challenges with dealing with complex JavaScript code led to custom tool requests to facilitate component development in the language.
TypeScript developers look for solutions that will not break compatibility with cross-platform standards and support. Knowing that the current ECMAScript standard proposal promises future support for classroom-based programming, TypeScript is based on that proposal. That causes JavaScript compilers with a set of syntax language extensions, a superset based on a proposal, which converts the extension to a regular JavaScript. In this sense, TypeScript is a preview of what is expected of ECMAScript 2015. A unique aspect that is not in the proposal, but added to TypeScript, is optional static typing that allows static language analysis, which facilitates IDE tools and support.
ECMAScript 2015 Support
TypeScript adds support for features like class, module, and arrow function syntax as defined in the 2015 ECMAScript standard.
Language features
TypeScript is a language extension that adds features to ECMAScript 6. Additional features include:
- Type an annotation and type compile-time check
- Type inference
- Type deletion
- Interface
- The enumerated type
- General
- Namespaces
- Tuple
- Waiting
The following features are supported again from ECMAScript 2015:
- Class
- Module
- The "arrow" syntax is abbreviated for anonymous function
- Optional parameters and default parameters
Syntactically, TypeScript is very similar to JScript.NET, another Microsoft implementation of the standard ECMA-262 language that adds support for static typing and classic object-oriented language features such as classes, derivatives, interfaces, and namespaces.
Compatibility with JavaScript
TypeScript is a superset of ECMAScript 2015, which is a superset of ECMAScript 5, commonly referred to as JavaScript. Thus, the JavaScript program is also a valid TypeScript program, and the TypeScript program can seamlessly use JavaScript. By default, the compiler is targeting ECMAScript 5, the current standard, but also capable of generating constructs used in ECMAScript 3 or 2015.
With TypeScript, it is possible to use existing JavaScript code, incorporate popular JavaScript libraries, and call codes generated by TypeScript from other JavaScript. Type the declaration for this library provided with the source code.
Type an annotation
TypeScript provides static typing via type annotations to enable check types at compile time. It is optional and can be ignored to dynamically use dynamic JavaScript typing.
Annotations for primitive types are number
, boolean
and string
. A weakly typed or dynamic typed structure is anything
.
The annotation type can be exported to a separate declaration file to create the type information available for a TypeScript script using a type already compiled into JavaScript. Annotations can be declared for existing JavaScript libraries, as was done for Node.js and jQuery.
The TypeScript compiler uses type inference to infer the type when the type is not assigned. For example, the add
method in the above code will be deduced as returning number
even if no return type annotations are provided. It's based on the static type left
and right
is numbers
, and the compiler knowledge generated from adding two numbers
number
. However, explicitly declaring the return type allows the compiler to verify the truth.
If no type can be inferred due to lack of declaration, then the default is the dynamic type any
. Values ââof any
type support the same operations as values ââin JavaScript and minimal static type checks are performed for operations at any
.
File declaration
When the TypeScript script is compiled there is an option to generate the declaration file (with the .d
extension) which serves as the interface for components in JavaScript that is compiled. In the process the compiler removes all functions and body methods and retains only the signature of the exported type. The resulting declaration file can then be used to describe the type of virtual TypeScript that is exported from a library or JavaScript module when third-party developers use it from TypeScript.
The concept of the declaration file is analogous to the concept of header files found in C/C.
Type handwritten declaration files for existing JavaScript libraries, just as you would for jQuery and Node.js.
The large collection of declaration files for popular JavaScript libraries is hosted on GitHub in DefinitelyTyped and Typing Registry. A command line utility called typing
is provided to help search
Class
TypeScript supports ECMAScript 2015 classes that integrate optional type annotation support.
Generic
TypeScript supports generic programming.
Module and namespace
TypeScript differentiates between module and namespace. Both features support ClassScript encapsulation of classes, interfaces, functions and variables into containers. Namespaces (formerly internal modules) use JavaScript function expressions that are immediately invoked to encapsulate code, whereas modules (formerly external modules) utilize JavaScript library patterns to do so (AMD or CommonJS).
Development tools
Compiler
The TypeScript compiler, named tsc
, is written in TypeScript. As a result, it can be compiled into regular JavaScript and can then be run on all JavaScript engines (eg browsers). The compiler package comes with host scripts that can run the compiler. It's also available as a Node.js package that uses Node.js as the host.
There is also an alpha version of the client-side compiler in JavaScript, which executes the TypeScript code quickly, after page loading.
The current version of the compiler supports ECMAScript 5 by default. An option is allowed to target ECMAScript 2015 to take advantage of language features exclusive to that version (such as generators). Classes, though part of the 2015 ECMAScript standard, are available in both modes.
Support IDE and editor
- Microsoft provides plug-ins for Visual Studio 2012 and WebMatrix, fully integrated support in Visual Studio 2013, Visual Studio 2015, and basic text editor support for Sublime Text, Emacs and Vim.
- Visual Studio Code is an open source open source source code editor developed by Microsoft based on Electron. It supports TypeScript in addition to several other languages, and offers features such as debugging and smart code completion.
- alm.tools is an open source cloud IDE for TypeScript built using TypeScript, ReactJS, and TypeStyle.
- JetBrains supports TypeScript with code completion, refactoring and debugging within its IDE built on IntelliJ platforms, such as PhpStorm 6, WebStorm 6, and IntelliJ IDEA, and Visual Studio Add-in and extensions, ReSharper 8.1.
- The Atom has a TypeScript Plugin by Basarat with support for fast code completion, navigation, formatting, and compilation.
- Cloud9 IDE online and Codenvy TypeScript support.
- A plugin is available for NetBeans IDE.
- A plugin is available for Eclipse IDE (Kepler version)
- TypEcs is available for Eclipse IDE.
- Microsoft provides TypeScript Plug-ins for Sublime Text.
- Cross Code Cloud IDE Codeanywhere supports TypeScript.
- The Webclipse An Eclipse plugin is designed to develop TypeScript and Angular 2.
- A standalone Angular IDE IDE is available through npm to develop TypeScript and Angular 2 applications, with integrated terminal support.
- Tide - The FontScript Interactive Development Environment for Emacs.
- Tsuquyomi - Vim plugin that uses TSServer and provides features like code completion, navigation and syntax and semantic error checking.
Integration with build automation tool
Using plug-ins, TypeScript can be integrated with build automation tools, including Grunt (grunt-ts), Apache Maven (TypeScript Maven Plugin), Gulp (gulp-typescript) and Gradle (TypeScript Gradle Plugin).
Releasing history
See also
- Constructor Closure
- Dart
- CoffeeScript
- Elm (programming language), functional compilation-to-JavaScript functionality with static typing
References
- "Webclipse: Eclipse Plugin" Genuitec. Retrieved on November 9th. 2016.
- "Angular IDE by WebclipseÃ,: Standalone IDE" Genuitec. Retrieved on November 9th. 2016.
External links
- Official website
- TypeScript project in GitHub
- TypeScript Language Specification
- CATS Cross Platform TypeScript Editor
- Create a 2013 presentation
- Awesome-TypeScript: List of community supported tools and resources associated with TypeScript
- TypeScript Training
Source of the article : Wikipedia