When TypeScript was introduced, several techies called it Microsoft’s answer to CoffeeScript or Google’s Dart; afterwards, they realized the difference though. TypeScript’s consistently increasing popularity grabbed the attention of both technology students and experienced developers. Hereby I am sharing my finding that I could explore during my exploration.
This a guest post submitted to ciphertrick.com. Authored by Kishan.
The comparison of TypeScript with CoffeeScript or Google’s Dart is actually not a right comparison.
TypeScript Well Explained
Several facts about TypeScript
- An Open Source language under Apache 2 License hosted on Github at https://github.com/microsoft/typescript
- Much focused to effectiveness of large-scale application development.
- Offers the optional static typing
The Language Features of TypeScript
- Type annotations
- Type inference
- Compile time type checking
- Optional, default and rest parameters
- Structural typing
- Arrow function expressions
- Tuple types
- Union types and type guards
Tooling for Typescript
- Supports different ECMAScript target versions
- Supports different module systems
- May produce SourceMaps
- Based on Language Service
IDE Support for TypeScript
- TypeScript Playground
- Visual Studio, VS Express for Web
- Visual Studio Online
- JetBrains IntelliJ / WebStorm / PHPStorm
- Text Editors
- Sublime Text, Vim, Emacs
- Cloud9 IDE
- And much more
Potential Products or Technologies that Uses TypeScript
- Visual Studio Online
- Mozilla Shumway
 Add a tsconfig.json.
 Convert your .js files to .ts file simply by changing the source code file’s extensions from .js to .ts. You need to suppress the errors as well. You can use any. for the same
 Write new code in TypeScript
 Start adding annotations to the old code
 Fix known bugs
TypeScript supports core ES2015+ features. Find the list of supported features at http://kangax.github.io/compat-table/es6
You can debug the TypeScript code in the browser or in an editor, if you have created appropriate files during build time.
You can use classes or functional programming techniques with TypeScript with the flexibility of opting out its specific features, if you wish to.
IntelliSense can be considered as one of the biggest advantages of TypeScript. It gives the active hints while code is being added. VScode, Atom, WebStorm, Sublime text or even command line editors, such as Vim/Neovim, Major available IDEs have excellent support for code completion.
The TypeScript syntax is more appropriate for C# or Java developers.
You can use common object-oriented patterns in TypeScript and extend existing classes to generate the new classes using inheritance.
Public, private, and protected modifiers
TypeScript offers adequate privacy features for members to be marked as public, private or protected. By default, each member is “public”. However, when you mark it as “private”, it will not be accessed from outside of its containing class. When you mark it as “protected”, more or less you are making it private with the exception of making it accessible by instances of deriving classes.
In TypeScript, there is a possibility to apply Read Only characteristic to a property by using the readonly keyword. You must initiate it at its declaration or in the constructor.
Code Consistency: The better code consistency directs you to the better maintenance and less dependency on individuals. Even though several developers work together on the large project, TypeScript enables to preserve supreme level code consistency. Moreover, TypeScript’s interfaces and access modifiers significantly allow the effective communication among APIs.
Prompt Error Catching: Once you use Custom Types in TypeScript, it really becomes easy for you to catch errors promptly during the early stage of the development lifecycle. You can easily pick it, if something is used or passed inaccurately. For example,
Why Angular and TypeScript is a great combination:
After considering the winning sides of TypeScript and brain streaming discussions with Microsoft, even Angular has started supporting TypeScript for its Angular 2 + versions. In fact, when it comes to defining code organization, TypeScript is substantial tool. It allows you to reuse the code as well as to encapsulate related pieces of code into TypeScript modules. It supports in providing transparency to the application architecture.
If you don’t have enough knowledge about statically typed or OOP languages, you may find difficulties in handling TypeScript. However, you can always learn it. Anyway, continuous learning is an essential part of the developer’s life.
The process of applying the TypeScript definitions for non-TypeScript libraries can be little annoying to you. It will lead you to better coding though.
I have encountered the discussions when developers have preferred to opt for TypeScript to leverage use ES6 features like modules, classes, arrow functions, and others at their best. I do not see it as a reasonable decision. You can attain the same objectives using Babel as well. I have come across the application in which TypeScript and Babel both are used. In fact, TypeScript has many other brighter sides to offer in a broader context.
Many developers believe that static typing in TypeScript will offer Tree Shaking. Tree Shaking is all about removal of dead code using static constructs like named module import/export and const. However, as of now TypeScript does not support Tree Shaking out of the box.
In this blog, I have covered all the major aspects of TypeScript that make it one of the most suitable languages for futuristic applications. Its advantages furnish the programmers with straightforward development experience along with increased productivity during the development phase and easy maintainability during entire lifecycle.
Kishan is a Software Engineer at Azilen Technologies. He has extensive experience of Full Stack Technologies and always Passionate about New Technologies and Challenging Development.
Leave a Comment