From the outside, TypeScript can feel like a mystery wrapped in an riddle.
stationary languages more early crimes, but the law is safe
A stationary language requires you to declare the data type of variables when you define them. For case, say I wanted to define the variable x as the number 24. In a stationary language, I would tell the computer,' This variable x, where I plan to store some figures, presently equals 24.'
The computer would also consider x a number- storehouse variable. 24 could ultimately change to 4, 240, or-7, but it would always remain anumber.However,' still, the language would throw up an error and the program would refuse to run, If we wanted to change x into the name' Jill.
stationary languages are safe to workwith.However, you'd be in trouble, If you ran a business and suddenly charged' Jill' bones to someone's bank account. stationary- compartmented languages help these feathers of crimes long before they be. exemplifications of common static languages include Java, C, and Rust.
Dynamic languages easier to write, but further crimes latterly on
A dynamic language, on the other hand, optimizes for speed and ease of use. stoutly- compartmented languages let you pass any type of data to a variable. You do not need to describe a value before you start using it. For illustration, take the ensuing line of Python, a popular stoutly- compartmented language
JS is dynamic and TS is stationary
let myString = 'this is js'
What TypeScript looks like
let myString: string = 'this is ts'
It's important to note that TypeScript allows you to define all feathers of types beyond simple variables. You can define more complex data types like arrays, objects, and functions, and you can indeed define the specific shape of an object in advance using interfaces.
Defining complex data structures when they are first assigned means complex law is much easier to understand and maintain over time, since each data structure comes with its own description of its intended use.
Functions can also only accept certain types, and fabrics and specific npm packages can come with type delineations that drastically lower the literacy wind for new tools( since your autocomplete can recommend the external libraries' syntax.)
It might be a good idea to set up TypeScript in your design if you
are working on a large design with a big platoon, where crimes are more common and safety is consummate.
are using external libraries and fabrics that offer type delineations, which can make writing your law much easier.
have the time to learn TypeScript and write it.
are writing a quick script or particular design and do not want to write important law.
value the capability to snappily make out a design over maintaining it and precluding crimes in the long term.
noway learned TypeScript and do not have time to do so.
As you might imagine, learning TypeScript requires anon-trivial time commitment. still, numerous inventors claim that it saves them time in the long run by precluding tedious debugging and enabling better autocomplete in their law editors, enabling them to write law briskly. TypeScript is so well- loved it made it to the# 2 position in StackOverflow's check of utmost loved programming languages, and coders find it dyads well with a variety of fabrics.