Loading, please wait...

A to Z Full Forms and Acronyms

What is TypeScript?

Apr 29, 2020 TypeScript, TS, 3321 Views
In this Article you'll See some of the key points about TypeScript.

What is TypeScript? 🧐 ⁣ ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣
is the typed version of JavaScript, built by Microsoft, compiles down to JavaScript, and tends to be less error-prone. ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣ ⁣
🀯What are the advantages of TypeScript? ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣ ⁣
The fact that it catches the errors in your code which leads to understanding your code better and makes it less error-prone, easily sets TS as one of my favorites. ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣ ⁣
πŸ‘‰πŸΌIf you see JavaScript like this: ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣ ⁣
export const Count = (value) =>{...}; ⁣ ⁣ ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣
You can write it on TypeScript like this:πŸ‘‡πŸΌπŸ‘‡πŸΌπŸ‘‡πŸΌ ⁣ ⁣ ⁣
export const Count = (value: number) =>{...}; ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣ ⁣
As you can see we just defined the type of our parameter, we're saying the "value" parameter should be a number and if it's not a number... our code will get an error... Woah!! I mean, that's amazing, it's like having a friend give you a hint that you may not understand your code but TS does! ⁣ ⁣ ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣
How to declare the syntax? πŸ€“ ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣ ⁣
Write the name of the variable followed by: and the type like this and then followed by = and the value of the variable: ⁣ ⁣ ⁣
β €β €β €β €β €β €β €β €β € ⁣ ⁣
let myVar: string = "hi"; ⁣ ⁣ ⁣

πŸ’¬ Have you ever used TypeScript? Shared your thoughts below πŸ‘‡πŸΌπŸ‘‡πŸΌ ⁣

A to Z Full Forms and Acronyms