22 days ago
2 min read

How to Upgrade TypeScript to the Latest Version Without Breaking Production

When teams decide to upgrade TypeScript to the latest version, most expect it to be a five-minute job. It can be, when you go in the right order. Skip a step, and you are debugging production at midnight. Follow them, and the whole thing wraps up in a clean pull request.

Here is the step-by-step process.

Step 1: Check your current TypeScript version

Before anything else, know where you are starting from.

npx tsc --version

Step 2: Install the new version on a separate branch

Never do this on main. Create a branch specifically for the upgrade, then install the latest TypeScript.

npm install typescript@latest --save-dev

Step 3: Run a dry check to see what breaks

This is the most important step. Run the compiler in check-only mode, which scans every file and reports errors without changing or producing any output.

npx tsc --noEmit

Read everything that comes back. Some errors will be major issues your code has been quietly carrying. Others will be new rules that the newer version enforces. You want to see all of it here, not after deploying.

Step 4: Fix the errors properly

Work through the errors one by one. Do not suppress them with any or @ts-ignore just to make the build pass; those become tough bugs later. Fix them properly, and your codebase comes out of the upgrade healthier than it went in.

Step 5: Update related dependencies

TypeScript does not work alone. Packages like ts-node, @typescript-eslint, and your framework type packages need to stay in sync with the TypeScript version. Run this and update anything tightly coupled to TypeScript alongside it.

npm outdated

Step 6: Run your full test suite

A passing build does not mean everything works correctly at runtime; your tests do that job. Run them all. If something fails, fix it before moving forward.

Step 7: Deploy to staging first

Before touching production, deploy to staging and do a quick check. Real usage sometimes surfaces things that tests do not.

Step 8: Merge, deploy, and monitor

Once staging looks good, merge to main and deploy. Watch your error logs for the first few hours. Edge cases under real traffic can still show up even after a thorough process.

That is the whole process to upgrade TypeScript to the latest version. The upgrade itself takes minutes. What takes time is working through the errors that surface, and those are worth fixing regardless, because the new version just made them visible.

Need Help Upgrading a Large Codebase?

On a small project, this is a couple of hours. On a large codebase with years of accumulated type debt, it is a different story. If your team is looking to upgrade TypeScript to the latest version without slowing down your delivery work, you can hire TypeScript developers who can help.

Appreciate the creator