What is the difference about it? I am using JS in React, should i use TS or i am fine with TS for while?
13 hours ago
silverwing101
:ts:
The main purpose of TS is to prevent type mismatch errors that can happen at run time because you tried to call a function on a variable that has a value which the function can't use (like trying to find the length of a number).
They have also expanded on this to allow you to declare that a variable can have only a fixed set of values (like an enum in SQL) which can prevent even more possible run time errors. This type-safety is what people who have come from lower level languages like C++ or Java feel comfortable with.
Also TS is a superset of JavaScript, so valid JavaScript is also valid TypeScript. Ultimately, TypeScript is just JavaScript with types.
You will have to convert this TS code to JS code during compilation tho cause browsers and nodejs cannot parse js (tho nodejs does have experimental TS support that just strips the types and runs it). Overall I'd if you wanna continue in web development, learning TypeScript will be a good decision (there are other alternatives for JavaScript with types but I think only TS is a proper superset of JS, the others deviate slightly in their syntax)
What is the difference about it? I am using JS in React, should i use TS or i am fine with TS for while?
The main purpose of TS is to prevent type mismatch errors that can happen at run time because you tried to call a function on a variable that has a value which the function can't use (like trying to find the length of a number).
They have also expanded on this to allow you to declare that a variable can have only a fixed set of values (like an enum in SQL) which can prevent even more possible run time errors. This type-safety is what people who have come from lower level languages like C++ or Java feel comfortable with.
Also TS is a superset of JavaScript, so valid JavaScript is also valid TypeScript. Ultimately, TypeScript is just JavaScript with types.
You will have to convert this TS code to JS code during compilation tho cause browsers and nodejs cannot parse js (tho nodejs does have experimental TS support that just strips the types and runs it). Overall I'd if you wanna continue in web development, learning TypeScript will be a good decision (there are other alternatives for JavaScript with types but I think only TS is a proper superset of JS, the others deviate slightly in their syntax)
use any