What is Type Script
Compatibility with JavaScript-
TypeScript is a strict superset of ECMAScript 2015, which is itself a superset of ECMAScript 5, commonly referred to as JavaScript.As such, a JavaScript program is also a valid TypeScript program, and a TypeScript program can seamlessly consume JavaScript. By default the compiler targets ECMAScript 5, the current prevailing standard, but is also able to generate constructs used in ECMAScript 3 or 2015.
With TypeScript, it is possible to use existing JavaScript code, incorporate popular JavaScript libraries, and call TypeScript-generated code from other JavaScript. Type declarations for these libraries are provided with the source code.
Type annotations
TypeScript provides static typing through type annotations to enable type checking at compile time. This is optional and can be ignored to use the regular dynamic typing of JavaScript.
The annotations for the primitive types are number
, boolean
and string
. Weakly- or dynamically-typed structures are of type any
.
Classes
TypeScript supports ECMAScript 2015 classes that integrate the optional type annotations support.
Generics
TypeScript supports generic programming.The following is an example of the identity function.
No comments:
Post a Comment
Feel free to ask me for any query regarding my post