Menu

TypeScript at Slack: how we converted and what we learned

Case study of converting a large codebase from JavaScript to TypeScript: it is not as painful as you might think.

On the Slack Engineering Blog, Felix Rieseberg writes:

We decided to use Microsoft’s TypeScript, which combines static type analysis with a compiler. Modern JavaScript is valid TypeScript, meaning that one can use TypeScript without changing a single line of code. This allowed us to use “gradual typing” by enabling the compiler and the static analysis early, without suspending work on critical bug fixes or new features.

In practice, switching the analysis and the compiler on without changing code means that TypeScript will immediately attempt to understand your code. It uses built-in types and type definitions available for third party dependencies to analyze the code’s flow, pointing out subtle errors that went previously unnoticed. Wherever TypeScript cannot understand your code, it will assume a special type called “any” and simply move on.

Categories

Meta

Ken Snyder is a Software Craftsman specializing in PHP and JavaScript. Ken works in Salt Lake city for Right Intel.
He is the co-founder of UtahJS, an educational non-profit aimed at promoting JavaScript in Utah.