LEARNING TYPESCRIPT AS A SOFTWARE DEVELOPER PUTS YOU IN HIGH DEMAND
Published: 2022-06-25 20:47:28

## **<u>What is TypeScript?</u>**
TypeScript is a programming language first developed by Microsoft in 2012. It is an open-source language developed as a superset of JavaScript. Its main ambition is to improve the productivity of developing complex applications. Any code valid in JavaScript is also valuable for TypeScript. However, the language introduces optional features like typing or object-oriented programming. TypeScript has been increasing in its popularity for the last couple of years. About 60% of JS programmers already use TypeScript, and 22% wish to try.

## **Types of TypeScript
**

For programs to be useful, we need to be able to work with some of the simplest units of data (numbers, strings, structures, boolean values, etc.) TypeScript supports the same types as you would expect in JavaScript, with an extra enumeration type thrown in to help things along.
**

- Boolean
**
The BOOLEAN data type stores TRUE or FALSE data values.

```
let isDone: boolean = false;
```
**

- Number
**
Just like JavaScript, TypeScript supports a number of data types. All numbers are stored as floating-point numbers. These numbers can be Decimal (base 10), Hexadecimal (base 16), or Octal (base 8).

```
let decimal: number = 6;
let hex: number = 0xf00d;
let binary: number = 0b1010;
let octal: number = 0o744;
let big: bigint = 100n;
```
**

- String
**
A sequence of character values is represented by an object called a string in TypeScript which is used to store text data and is a primitive data type consisting of several helper methods and these string values are enclosed in either single quotation marks (') or double quotation marks (").

```
let color: string = "blue";
color = 'red';
```
**

- Array
**
TypeScript, like JavaScript, allows you to work with arrays of values. Array types can be written in one of two ways. In the first, you use the type of the elements followed by [] to denote an array of that element type:

```
let list: number[] = [1, 2, 3];
```
The second way uses a generic array type, Array<elemType>:

```
let list: Array<number> = [1, 2, 3];
```
**

- Object
**
The TypeScript object type represents all values that are not in primitive types i.e. anything that is not _number_, _string_, _boolean_, _bigint_, _symbol_, _null_, or _undefined_.

**

- Any & Unknown
**
While any as a type can cover, well, anything that you wish, unknown is its type-safe counterpart. Whenever you want to escape the type system, and enables you to assign any JavaScript variable to it. It is frequently used to model incoming variables (from third-party APIs, for example) that have not yet been checked and whose type is unknown. The unknown is a lot like any, but it won’t let you perform any operations on the variable before it is explicitly type-checked.

**

- Void
**

Void is used when there is no value returned, for example, as the return type of functions that return nothing.

**

- Null and Undefined
**
In TypeScript, both undefined and null actually have their types named undefined and null respectively. Much like void, they’re not extremely useful on their own:

```
let u: undefined = undefined;
let n: null = null;
```
**

- Never
**
Never is the return type for something that should never occur, like a function that will throw an exception.

**

## Features and Components
**
TypeScript was initially supported only in Microsoft’s Visual Studio code editor because TypeScript is maintained by Microsoft. But as TypeScript grew legs, more code editors and IDEs began started supporting it either natively or with plugins.

TypeScript is essentially a JS linter. Or, JS with documentation that the compiler can understand. Therefore, in contrast to other languages like CoffeeScript (which adds syntactic sugar) or PureScript (which does not look like JavaScript at all), you do not need to learn a lot to start writing TypeScript code.