Skip to main content

What is Typescript

What is TypeScript?

TypeScript is a modern age JavaScript development language. It is a statically compiled language to write clear and simple JavaScript code. It can be run on Node js or any browser which supports ECMAScript 3 or newer versions.

TypeScript is an open-source pure object-oriented programing language. It is a strongly typed superset of JavaScript which compiles to plain JavaScript.

Why TypeScript?

JavaScript is a great tool to make web pages interactive and lively. However, when it comes to developing large scale applications, developers often find it difficult to maintain the code, as JavaScript is a loosely typed language.

Here is where TypeScript comes in. It provides optional static typing, classes, and interfaces. This makes it easier for developers to write and maintain complex JavaScript programs.

Features of TypeScript

TypeScript comes with the following features:

1. Static Type-Checking

TypeScript uses static typing and helps type-check your code before running it. You can assign a type to your variables when you declare them and TypeScript will ensure you don't accidentally change the variable type later in your code.

2. Class-Based Objects

TypeScript supports the ES6 class syntax, but also adds some additional features not found in ES6 like interfaces and abstract classes.

3. Modularity

TypeScript, like JavaScript, supports module-based code organization. Modules in TypeScript can contain both code and declarations.

4. ES6 Feature Support

TypeScript supports most features from ECMAScript 2015 (ES6 and ES7) including classes, modules, arrow functions, and optional chaining.

5. Syntax

The syntax is a set of rules on how programs in TypeScript are constructed. TypeScript syntax is a superset of ECMAScript 6 (ES6) syntax. ES6 is a set of updates to JavaScript and is the second major revision to JavaScript.

How TypeScript Works?

TypeScript is not directly run on the browser. It needs a compiler to compile and generate in JavaScript file. TypeScript source file is in ".ts" extension. We write TypeScript codes in this file and then compile the file in JavaScript using TypeScript compiler. The browser cannot understand TypeScript directly. It can only execute JavaScript. Therefore, typescript needs to be compiled into JavaScript using the TSC (TypeScript Compiler).

Conclusion

In summary, TypeScript provides a complete description of each component of the code and can be used for developing large applications with a strict syntax and fewer errors. It is powerful and flexible, making it a worthwhile addition to any JavaScript developer's toolbox.