Making backend developers comfortable with JavaScript
If you’re a backend developer, then you will have worked on or come across .NET Framework with all its capabilities and powerful tools.
used to and the compiler produces the JavaScript that accomplishes the intent. However, backend developers have been hesitant to really get into JavaScript due to its loose approach to object definition.
In the TypeScript editor, you can’t add an additional property without getting a warning. Constructors, though available in JavaScript, are enhanced with the TypeScript tooling, again by enforcing the creation of the object during compile time and not allowing the object to be created without passing in the proper elements and types in the call. Not only can you add the constructor to the class, but you can make the parameters optional, set a default value or shortcut the property declaration. Classes in TypeScript also provide inheritance. A helper class usually assists in the inheritance functionality. As a side note, this helper function has the exact same signature regardless of the source, so if you’re organising your JavaScript in multiple files and use a utility such as SquishIt or Web Essentials to combine your scripts, you might get an error depending on how the utility rectifies duplicated functions.
Modules in TypeScript are the equivalent of namespaces in the .NET Framework. They’re a great way to organise your code and to encapsulate business rules and processes that would not be possible without this functionality (JavaScript doesn’t have a built-in way to provide this function). The module pattern, or dynamic namespacing, as in JQuery, is the most common pattern for namespaces in JavaScript. TypeScript modules simplify the syntax and produce the same effect.
Another nice benefit of modules is that you can merge them. If you create another module, TypeScript assumes that the code in the first module and the code in new module are both accessible through statements, just as in namespaces. Modules facilitate the maintainability and organisation of your code. With them, sustaining large-scale applications becomes less of a burden on development teams.
The features TypeScript adds to JavaScript development are small, but yield large benefits to backend developers who are accustomed to similar features in the languages they use for regular Windows application development.
TypeScript is not a silver bullet and it’s not intended to be, but for anyone hesitant to jump into JavaScript, TypeScript is a great language that can ease the journey.