# Introducing Typescript at Cambridge University Press

By Jag Reehal, 2021-02-22. Canonical: https://arrangeactassert.com/posts/introducing-typescript-at-cambridge-university-press/

<!-- Excerpt Start -->

Having worked with many clients who struggled to maintain Javascript projects, [Typescript](https://www.typescriptlang.org/) 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.

<!-- Excerpt End -->

<svg class="h-48 w-48 float-right pl-12" style="shape-outside: circle(50%)" viewBox="0 0 256 256">
  <title>Typescript logo</title>
  <path fill="#007ACC" d="M0 128v128h256V0H0z"/>
  <path d="M56.611 128.85l-.081 10.483h33.32v94.68H113.42v-94.68h33.32v-10.28c0-5.69-.122-10.444-.284-10.566-.122-.162-20.399-.244-44.983-.203l-44.739.122-.122 10.443zM206.567 118.108c6.501 1.626 11.459 4.51 16.01 9.224 2.357 2.52 5.851 7.112 6.136 8.209.08.325-11.053 7.802-17.798 11.987-.244.163-1.22-.894-2.317-2.52-3.291-4.794-6.745-6.867-12.028-7.232-7.76-.529-12.759 3.535-12.718 10.32 0 1.992.284 3.17 1.097 4.796 1.707 3.535 4.876 5.648 14.832 9.955 18.326 7.884 26.168 13.085 31.045 20.48 5.445 8.25 6.664 21.415 2.966 31.208-4.063 10.646-14.14 17.88-28.323 20.277-4.388.772-14.79.65-19.504-.203-10.28-1.829-20.033-6.908-26.047-13.572-2.357-2.601-6.949-9.387-6.664-9.875.122-.162 1.178-.812 2.356-1.503 1.138-.65 5.446-3.13 9.509-5.486l7.355-4.267 1.544 2.276c2.154 3.291 6.867 7.802 9.712 9.305 8.167 4.308 19.383 3.698 24.909-1.26 2.357-2.153 3.332-4.388 3.332-7.68 0-2.966-.366-4.266-1.91-6.5-1.99-2.845-6.054-5.243-17.595-10.24-13.206-5.69-18.895-9.225-24.096-14.833-3.007-3.25-5.852-8.452-7.03-12.8-.975-3.616-1.22-12.678-.447-16.335 2.723-12.76 12.353-21.658 26.25-24.3 4.51-.853 14.994-.528 19.424.57z" fill="#FFF"/>
</svg>

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](https://twitter.com/rtfeldman) to clients and at the local Javascript meetup group in Cambridge.

<div style="--aspect-ratio: 16/9;">
<iframe width="560" height="315" src="https://www.youtube.com/embed/IcgmSRJHu_8" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>

During the talk, I showed how companies could adopt typed Javascript using both Flow and Typescript incrementally.

## Evangelising Typescript

Having taught developers at [Arm](https://www.arm.com/) how to use [Stencil](https://stenciljs.com/), 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.