JavaScript to TypeScript in Serverless

JavaScript to TypeScript in Serverless

Oct 04, 2021

The journey of moving from JavaScript to TypeScript in Serverless.

JavaScript is a great language aside from the unexpected runtime errors and results , bad debugging experience ,poor refactoring experience, readability and predictability , the list goes on.

If You are a JavaScript developer ,you already know reasons we migrated to typescript. Working with typescript our code has become more predictable, everything stays the way it was initiаlly defined to be. In case a variаble is deсlared as a string, it'll always be a string and won’t turn into Boolean. This enhances the likelihood оf functions working the way they are expected to.

Our code has become more expressive and readable. The adding of strict types has made the code more self-expressive, Any new members can see the design intent of those who originally wrote the code without scratching your head a few times. This is very valuable for teams working on the same project. A code that speaks for itself can counterbalance the lack of direct communication between team members.

Our Debugging experience. TypeScript is able to detect more common bugs at the compile time. Its not 100% bullet proof but it does make a difference in making our programs less error prone and saves a lot of our time bounty hunting for bugs.

Refactoring  or updating the app without changing its behavior is needed to keep the codebase robust and maintainable. TypeScript makes this important process less painful and frustrating, Our IDEs are know a lot about our code Types and are able to scan for references and definitions .

How has our Journey to Serverless Typescript been ?

If I said it was a smooth journey I would be lying and also if I said it was a hard one. Were lucky enough to because we were about to rewrite an application and starting it ground up.

The hardest part of working with Typescript Serverless was with documentations and references , there is little reference materials. Getting started with configurating Serverless was in some cases a little frustrating ,especially given that we went with the typescript Serverless config file instead of using YAML. Once we got everything setup ,the code was extremely neat clean and easy to work with and easy to build upon, Our design decisions also played an important part in making this all possible and typescript has served as the perfect instrument to for us to fully express our ideas. Most of the problems we faced with working with JavaScript cease to exist. I am happy to say that our development time has decreased and we now have a nice steady growth.

If you still undecided on whether to start your next project in JavaScript or Typescript, fear not you will not regret the decision. My only advice is to take full advantage of typescript,think in strong types.

Serverless provides a perfect startup template template for getting started with Typescript on Serverless framework.

to get started make sure you have serverless cli installed globally on your system ,then on your projects directory open a terminal and type the following command:

serverless create aws-nodejs-typescript --path my-serverless-project

Ti piace questo post?

Offri un libro a Nicolas Hlulani Maluleke

More from Nicolas Hlulani Maluleke