Angular 7

What is TypeScript?

What is TypeScript?

TypeScript (TS) is superset of JavaScript developed by Microsoft. TypeScript is supported by two companies Microsoft and Google. 

Microsoft because it is the creator of TypeScript and by Google as it was used to develop Angular from version2 to Angular12 (the current version). It is official language to build Angular2+ apps.

TypeScript is developed on the top of JavaScript. It supports all the concepts and features of JavaScript.

TypeScript is to create a super-set of JavaScript. It provides powerful OOP (Object Oriented Programming) features like inheritance interfaces and classes, a declarative style, static typing, and modules. Although many of these features are already in JavaScript, they are different as JavaScript follows a prototypical-based OOP, not class-based OOP.

TS features make it easy for developers to create complex and large JavaScript applications that are easier to main and debug.

TypeScript can be work with both client-side programming and server-side programming. TypeScript can be used in client-side program development, using Angular framework. It can be used in server-side program development, using NodeJS platform.

To work with TypeScript, we require to be used in modern code editors / IDE's, such as Visual Studio Code, Atom, Sublime Text, Web Storm, Eclipse etc.

As we know browser only understand JavaScript language. Browser doesn’t support TypeScript.

TypeScript code can’t be executed directly by the browser.

So, TypeScript code should be converted into JavaScript code, and we have to import JavaScript language file into the web page. Browser executes JavaScript. We use "TypeScript Compiler" (tsc) to compile / transpile "filename.ts (TypeScript file)" to "filename.js (JavaScript file)". We won't load TypeScript file into the browser. We will load & execute JavaScript file into the browser

 

TypeScript is a compiled language which means we’ll need to transpile it into JavaScript to be able to run it in web browsers which do only understand one programming language. Fortunately, the TS transpiler integrates well with the majority of build systems and bundlers.

TypeScript file ends with .ts extension. We can install the TypeScript compiler using npm and then you can call it by running the tsc source-file.ts command from the terminal.