How to Convince Team to Adopt TypeScript
Tags: typescript, javascript, tutorial, react
Published: 2020-05-07 19:41:37

It's hard convincing a team to adopt any technology. The benefits have to outweigh the costs, and often times, marginal benefits are considered not worthy of investment.

What if we can have a typed system from back-end to the front-end? What if we can ensure that if a column is a string type in the database will be a string type in the front-end? This is an absolute game changer and will help the organization dodge a whole family of bugs that result from type conversions.

Here are the 5 steps we can take to convince a team to adopt TypeScript.

## 1. Articulate the vision

The reason for adopting TypeScript has to be bigger than just a static checker for JavaScript. Be excited about the vision! This is not about TypeScript, this is about improving the developer experience (an thus the user experience) with a strongly typed system from database to the user.

## 2. Show generated types

TypeScript seems like a lot of work at first...now we have to type everything, learn new syntax, learn new tools, and so on.

Instead of showing how to add typing to an existing file, it is a lot more magical to show generated types. Whether the organization is using GraphQL or some other API, there are tools to generate types so that we know what the response is going to be.

Knowing what types a response is going to be from an external API is a huge win! This is the magical moment that illustrates how TypeScript will save us time, instead of add more boilerplate.

This is how we can generate types if we have a GraphQL API:
https://dev.to/andyrewlee/apollo-client-hooks-fragments-queries-mutations-and-generated-types-3old

## 3. Show integration with front-end framework

Next, show how TypeScript can be integrated with the front-end framework. This way, engineers can learn just the parts needed to become productive instead of being faced with a daunting task of learning a new language.

Here is how we could introduce TypeScript to React engineers:
https://dev.to/andyrewlee/typescript-onboarding-for-react-engineers-5edi

## 4. Communicate with each engineer

This step is crucial! It is important to talk to every engineer that will be affected and get feedback. Adopting TypeScript is a group effort and just having one engineer go rogue and start using the `any` type is enough to jeopardize the migration. Asking engineers to change the language that they work with is a big ask, and it is important for us to empathize and get a pulse from the organization.

## 5. Present formal document with roadmap

For the final step, it is important to formalize our proposal with a document. This is where we address the concerns that we heard from communicating with other engineers, and show how we can turn our vision into reality.

Here is how a document might be structured:

* Objective: Have typed system from back-end to front-end by generating types

* Motivation: Reduce bugs, improve code quality

* Implementation: Illustrate how we can generate types from back-end and how we can use it with our favorite front-end framework

* Costs: Tooling to auto-generate, transpile TypeScript code, learn new syntax

* Alternatives: Flow, ReasonML, Elm. TypeScript has the biggest community which is important to have modules that are typed.