Getting Started With Typescript
Tags: typescript, webdev, beginners, programming
Published: 2023-07-15 07:07:58

######Table of contents:

- [What is Typescript](#defination)

- [Why should we use Typescript](#use)

- [Advantages of Typescript](#advantages)

- [Disadvantages of Typescript](#disadvantages)

- [Difference between Typescript and Javascript](#diff)

##What is Typescript<a name="defination"></a>:
Typescript is a syntactic superset of Javascript which adds static typing. It shares the same base syntax(the way we write text to form a program) as Javascript but adds something to it. It is developed and maintained by Microsoft.

##Why should we use Typescript<a name="use"></a>:

- Javascript is a loosely typed language which can be difficult to understand what types of data that are being passed around Javascript.
- Typescript allows specifying types of data that are being passed around within the code. 
- Typescript uses compile time checking which means it checks if the specified types match before running the code.
- Typescript is compatible with all versions of Javascript which makes sure it has a smooth transition and long portability.


###Advantages of Typescript<a name="advantages"></a>:

- **Predictability:**  In Typescript, everything stays the way it was initially defined. If the variable is declared as a string, it will always be a string.

- **Readability:**  Due to adding strict types and other elements that make the code more self-expressive, you can see the design intent of developers who wrote the code.

- **Rich IDE support:**   Information about types make the code editor and IDE much more helpful in that they can offer features like:  
       1. code navigation.
       2. autocompletion. 
       3. can get feedback while typing.
       4. flags errors as soon as they occur.

- **Cross-platform and cross-browser compatibility:**  Every platform that runs Javascript works with Typescript as well after the compiler translates it into vanilla Javascript, usually IDE's come with built-in Typescript compiler.

###Disadvantages of Typescript<a name="disadvantages"></a>

- **Not true static typing:** Static typing feature in Typescript is optional, Typescript is transpiled into untyped Javascript, so there is always the risk of weird type conversions at runtime.

- **Recruiting Typescript developers:**  It might be a pain in the neck because some developers are not interested in learning Typescript because they are comfortable with Javascript. Teams that are already use Javascript become more productive with Typescript after 2-3 months and fluent with Typescript only after half a year, so educating staff can be a hurdle.

###Difference between Typescript and Javascript<a name="diff"></a>
**Learning curve**

- Typescript is a superset of Javascript. To write Typescript you should have a basic understanding and knowledge of Javascript and OOP concepts.

- Javascript has a popular and easy to learn scripting language and many developers use Javascript with CSS and HTML to create web applications.

**Static typing**

- Typescript supports static typing.

- Javascript does not support strongly typed or static typing. It is a loosely typed language.

**Error detection**

- Typescript highlights errors during the development time.

- Javascript highlights errors during runtime.