Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Nataliya Muriy
Marketing Content Creator - you name it, she'll write it!
Posted on Apr 20th 2017

TS or JSTypeScript or JavaScript?  Now, that is the question!  If TypeScript, a typed superset of JavaScript, compiles down to JavaScript, the obvious query is why have it in the first place.  Another logical inquiry is whether it’s ideal for everyone, how and where it can be used.

There are two good reasons why developers should bother learning TypeScript (TS): the added features it offers and the chance to innovate freely.  What does TS add to JavaScript (JS)?  Among the traits that stand out are interfaces, abstract classes, and algebraic data types.  Being a transpiled language, TS implements a feature in question in raw JS; meanwhile, the developer can work with the interfaces without worrying about the details.  Besides, since it starts off based on JS, TypeScript helps you avoid the hassle of making experiments with new syntax — instead, it allows you to build on it while not deviating from the standard too much.  The result?  There is more room for innovation in such a user-friendly environment which makes your life so much easier (source).

TypeScript allows developers to “take Arms against a Sea of Troubles” under many circumstances.  For instance, if the code base is of significant size or if a project calls for multiple TypeScriptdevelopers, many typical errors can be avoided, including situations when breaking changes are introduced (TS serves a kind of safety net).   Also, if the development team is already comfortable with a statically-typed language, if a framework or library recommends the use of TS, or when there is no desire to handle a string of type checks).  Besides, if you are looking to replace the use of Babel, TS is the perfect choice: it makes it possible to transpile ES6 code into ES5 because the former is essentially a subset of TypeScript.  At the same time, it includes features like enums and allows you to initialize member variables in a constructor (source). 

With TypeScript, developers can give a hand to the user too: by transpiling just once, they avoid the trouble of having to go through that every time a page is loaded.  Even though it is possible to transpile in browsers now, it’s not a way to go — application/webpage performance is affected by this extra step.

The only downside of TS is that its use requires some extra work related with type definitions for JS libraries and frameworks, as well as having to deal with some strange debugging cases caused by inefficient support for variables in Sourcemaps.  Besides, sometimes there simply isn’t enough time to generate the extra code that will be required when transpiling — certain features like inheritance, enum, generics, and async/await require that.  And yet, TypeScript is here to help us solve the great dilemma in web development.  The answer is, “TO BE”!

bob loves TS

In the end, “Whether ’tis nobler in the mind to suffer the slings and arrows of” learning TS, each and every developer and team should decide for themselves.  Nevertheless, It’s worth the headache for those working professionally (even learning as little as 5% of it is considered very positive) and, in reality, it’s not such a hard thing to do for those who already know JS.  Besides, since TS is a language with a compiler, it goes beyond what Babel — which is only a compiler — can do.  A developer using TypeScript benefits by the compiler/editor being able to point out many issues real-time; meanwhile, with JS you have to test your app in the browser and hopefully find the root issue. Thus, “bearing those ills” of learning TS is the way of the future (source).

TypeScript can be used with our Angular IDE, Webclipse plug-in and MyEclipse IDE.