A TypeScript 7 Upgrade Broke Next.js Server Startup

Postmortem:

The full-stack project uses Next.js, and every previous release went smoothly. But yesterday's release suddenly failed, and the entire Node.js server simply would not start. We couldn't pin down the cause, and worse, even the rollback failed.

Later I remembered seeing the news that morning that TypeScript 7 had shipped, and guessed it might be the culprit. So I checked the log in Figure 2 and found it was indeed related to TypeScript.

Then I went to the issues page on the official Next.js GitHub, Figure 3, and only then discovered that quite a few developers had already run into this while TypeScript 7 was still an RC, but five days on it still hadn't been fixed.

By the time the stable release shipped, the problem was fully exposed.

Although the corresponding PR was submitted two days ago, it still hasn't been merged.

For a project with 30 million weekly downloads, this really shouldn't happen.

Solution:

AI suggested I rename next.config.ts to next.config.mjs, but I felt that only treats the symptom, not the root cause — and I'm a bit of a neat freak, so I didn't want unnecessary JS code mixed into a TypeScript project.

The approach I ended up choosing is what Figure 4 shows: for now, don't exclude the packages in devDependencies. That way node_modules will contain TypeScript, and Next.js won't reinstall TypeScript on its own.

That said, this is still just treating the symptom. Going forward, I'll wait for a Next.js update ~