What is 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 👇🏼👇🏼