What is Typescript?

1. Typescript is a typed superset of JavaScript. JavaScript that scales. It's not replacement of JavaScript nor does it add any new feature of JavaScript.
2. It's compiled to generate JavaScript.
3. It was designed by Anders Hejlsberg (founder of C#) at Microsoft. Its open source and can be used in any place where we would need JavaScript.
4. Its object oriented and supports core features like interfaces and classes.
5. Typescript generated JavaScript can reuse all of the existing JavaScript frameworks, tools, and libraries.
6. Also any valid .js file can be renamed to .ts and compiled with other Typescript files.
7. The reader of this tutorial needs to have good knowledge on Object Oriented Programming and basic knowledge on JavaScript.
8. It’s not mandatory to strongly type everything when we are type scripting.
9. There are almost 40 languages which are superset of JavaScript. On which they generate .js on compiling, typescript is one of these languages.
Few of the languages are: typescript, purescript, coffeescript, livescript


Versions:
1. Typescript 0.8 was released on Oct 2012
2. Typescript 0.9 was released in 2013
3. Typescript 1.0 was released in 2014
4. Typescript 2.0 was released on Sep 22 2016

Benefits of TypeScript:
1. It compiles the code and generate syntax errors if any. This helps to highlight errors before the script is executed.
2. Because of Object Oriented features, it's reusable and easier to manage in large and complicated projects.
3. Angular 2 framework is written in Typescript and it’s recommended that developers use the language in their projects as well.
4. Due to the static typing, code written in Typescript is more predictable, and is generally easier to debug.

Small example:

Ex: Hello world

function sample() {
    var message: string = "Hello world"
console.log(message);
}
sample();

No comments:

Post a Comment