TypeScript is JavaScript which is designed to scale web applications.
As an object-based scripting language, JavaScript is designed by Netscape in 1995. It has an open standard (ECMAScript) and a huge developer community.
TypeScript is an object-oriented language designed by Microsoft in 2012. It is a superset of JavaScript and can be used both a language and a set of tools. It provides optional static typing, which can help to catch errors as they appear making it ideal for large team collaborations.
TypeScript can point out compilation errors at the time of development.
It, as mentioned above, offers static typing which allows catching type errors at compile time and therefore gives a less painful development experience.
It is great for large team collaborations.
// TypeScriptfunction fetchUserID(isUser: boolean) : string {if (isUser) {return '94321';}return 'username not present';}// throws: error TS2345: Argument of type '"true"'// is not assignable to parameter of type 'boolean'.let userId = fetchUserID('true');
In the above code, we are passing a string to fetchUserID()
function which is expecting a boolean variable. So, it will throw an exception:
Argument of type true
is not assignable to the parameter of type boolean.
TypeScript has the following three sections:
Language: It is an object-oriented language which can be broadly divided into three things:
TypeScript compiler: Translates the instructions written in TypeScript to JavaScript.
TypeScript language service: Supports editor operations such as: