Migrating from JavaScript to TypeScript

January 13, 2020

By Benny Neugebauer, Web Development Team Lead at Wire

When it comes to switching to a new programming language, timing is of the essence in order to land qualified programmers for the project. The language must be new enough to bring technical progress, and at the same time tested and disseminated in such a way that there are enough qualified programmers who will enjoy working with it.

Not so long ago, we decided to migrate the programming language in the web development team. This shift didn't only maintain the platform's high technical level but also made it faster, easier, and overall more convenient for programmers to work with. The change represented an initial financial investment to keep the technical debt low and eliminate technical problems in the long run.

Screen Shot 2020-01-09 at 10.52.04 AM

Changing Wire's programming language

Before the change, we had set ourselves a goal: attract talented programmers with new and improved languages. We first needed to consider the costs of such a change, but looking ahead, faster programming creates a long-term competitive advantage in developing new features –making the shift to new programming languages worthwhile. It was also assumed that the reverse function would eventually reduce the speed of development because modern programming languages would offer new formulation possibilities and language constructs, leading to better functions and clean code.

The development of new functions is often a metric for executives – but in this case, updating the development languages won't bring in competitive features right away. In the long run, however, programming can be done better, faster, and with fewer errors (usually achieved by the software on the first attempt through quality assurance). This means that change requests can be implemented and delivered more quickly, resulting in higher customer satisfaction.

A new phase with TypeScript

During the first three months of the changeover phase, our web team focused on familiarizing itself with the new language. It quickly became apparent that TypeScript masters the patterns of functional and object-oriented programming and that its strong typing reduces the number of errors. The context-sensitive completion suggestions also accelerate the programming process.

The strong typing is especially well received by programmers. Not only are typing errors detected, but the availability of objects or values is also continuously checked. This eliminates many sources of error. At the same time, TypeScript can use any Vanilla JavaScript without having to change the JavaScript code, and can thus be used in a variety of ways. The full translation of Wire's JavaScript code is still ongoing, but the migration has already started. The on-the-fly changeover posed another challenge but a step by step JavaScript migration means there are no service restrictions for the end user.

In conclusion

It takes several steps, some of which are quite complex, to make a clean change from JavaScript to TypeScript in an existing project. However, such a change can be done step by step and without any pressure to move. Even by using the TypeScript compiler as a pure analysis tool for JSDoc comments, the advantages of typing become apparent. The analysis of crash reporting at Wire has shown that the most frequent cause of errors in JavaScript code is calling functions of undefined objects. A strict TypeScript code base prevents such errors.

JavaScript is also valid TypeScript code, so that common JavaScript libraries can be reused. The language affinity of TypeScript and JavaScript makes it easier for developers to change over, since no completely new syntax has to be learned. This has a positive effect on recruitment, as existing talent can be drawn on. TypeScript maintainers provide documentation and a live editor on their own website for learning the language. This keeps the entry barrier into TypeScript low and reduces costs for training material and/or external consultants to a minimum.

The original article published in German can be found here.

Back to all posts
ProductWire ProWire RedWire EnterprisePricingWhy Wire?
ResourcesDownloadSupport & FAQResellers & PartnersSource Code
© Wire Swiss GmbH