Arrange Act Assert

Jag Reehals thinking on things, mostly product development

Introducing Typescript at Cambridge University Press

22 Feb 2021

Having worked with many clients who struggled to maintain Javascript projects, Typescript was a no brainer when choosing what to use for the project I was leading.

In this post, I'll share what and how I managed the challenges of introducing and using Typescript.

Typescript logo

While Typescript adoption grew, I was always surprised how many of my clients chose not to use it.

Some firmly held the view Javascript "wasn't Java" and shouldn't be typed, others said their projects were simple and wouldn't benefit from strong typing.

Those who understood the benefits didn't know they could adopt Typescript incrementally without rewriting everything in one go.

To convince my clients the benefits of Typescript was more than type safety, I presented a talk based on "Making Impossible States Impossible" by Richard Feldman to clients and at the local Javascript meetup group in Cambridge.

During the talk, I showed how companies could adopt typed Javascript using both Flow and Typescript incrementally.

Evangelising Typescript

Having taught developers at Arm how to use Stencil, a library that required UI components to be written in Typescript, I had learnt how to train colleagues without them feeling overwhelmed.

My aim was for anyone working on my project to contribute, even if they had little or no experience using Typescript.

We did many pairing sessions and shared ideas, concepts and patterns while avoiding pitfalls and keeping things simple and easy to understand.

It was fine for a developer to add ts-ignore comment at the top of a file and exclude a file from being typed checked during a feature's development.

This meant developers could focus on the feature they were building and share preview URLs with stakeholders, product owners and testers earlier during the development process. Meanwhile, we worked collaboratively behind the scenes to ensure everything was type-checked before merging the feature branch.

For the adoption of Typescript to be successful, we needed to be able to demonstrate the value.

Compared to similar projects at Cambridge University Press, which displayed information for books and articles, our codebase was cleaner as we were able to differentiate between types.

Over the next few months, I'll post more examples about how Typescript enabled us to have an awesome developer experience.

How did using TypeScript workout?

I'm confident Typescript will be adopted in both existing and future projects at Cambridge University Press.

Developers enjoyed using Typescript as it enabled them to focus on building features benefitting from better IntelliSense and faster feedback in their IDE than executing code within a browser. The organisation benefited from increased productivity, fewer bugs and having a product that was easier to maintain and extend.