Back to BlogTypeScript

TypeScript 6.0 Emptied Your types Array, and skipLibCheck Turned the Hole Into any

TypeScript 6.0 makes the tsconfig types default an empty array, so @types packages are no longer auto-loaded. The missing-process errors are easy. The real problem is what happens inside your dependencies' .d.ts files when skipLibCheck is on, because unresolved globals there degrade to any without a single error in your build.

TypeScript 6tsconfigskipLibCheck@typestype safety
TypeScript 6.0 Emptied Your types Array, and skipLibCheck Turned the Hole Into any

TypeScript 6.0 changed one compiler default, and for about a day my feed was the same screenshot over and over: Cannot find name 'process'. People fixed it in thirty seconds, posted the diff, moved on.

That one's fine. Loud errors are a gift. I'm more worried about the version of this break that doesn't error at all, which is what happens on any repo running skipLibCheck: true. Which is most of them.

What actually changed

Up through 5.9, if you didn't set types in your tsconfig, tsc walked node_modules/@types and dumped the globals from every package it found into every file in your program. Install @types/jest for one test folder and suddenly describe was a valid global in your production API code too. Sloppy, but convenient, and nobody thought about it.

In 6.0 the default is []. Nothing gets picked up automatically. You list what you want:

{
  "compilerOptions": {
    "types": ["node", "vitest/globals"]
  }
}

Worth being precise about what types controls, because this trips people up: it only governs *automatic* inclusion of ambient type packages. An explicit import type { Request } from "express" resolves exactly like it always did. A /// <reference types="node" /> still works. The setting is about globals that arrive without you asking.

There's an escape hatch, "types": ["*"], which is a special token rather than a glob and restores the old scan-everything behaviour. The release notes steer you toward an explicit list instead, and I agree, but it's a legitimate way to unblock a build on a Friday.

The loud failures are the good ones

Here's the full set of things that break noisily, and they all break the same way:

process.env.DATABASE_URL;   // TS2304: Cannot find name 'process'
Buffer.from("hi");          // TS2304: Cannot find name 'Buffer'
describe("thing", () => {}) // TS2304: Cannot find name 'describe'
import logo from "./logo.svg"; // TS2307, the declare module "*.svg" is gone

Add the package to types, done. If you're in a monorepo, do it per package rather than hoisting one giant list into the base config, because the whole point of the change is that your server code shouldn't see describe and your browser code shouldn't see process.

The quiet one

skipLibCheck: true tells tsc not to report errors found inside .d.ts files. Almost everyone turns it on, because one badly typed dependency otherwise lights up your build with errors in code you don't control.

Now stack the two behaviours. A dependency ships a declaration file that references a global it never imported:

// node_modules/some-image-lib/index.d.ts
export declare function resize(input: Buffer, width: number): Promise<Buffer>;

That file has always assumed Buffer is just lying around in global scope, because under the old default it always was. Drop @types/node out of automatic loading and Buffer no longer resolves. That's an error, inside a .d.ts, which skipLibCheck swallows. The unresolved name becomes the error type, and the error type behaves like any everywhere downstream.

So your own code, which you believed was type checked, now compiles this:

// Before: Argument of type 'string' is not assignable to parameter of type 'Buffer'
// After TS 6.0 + skipLibCheck: compiles clean, crashes at runtime
await resize("./cat.png", 800);

const out = await resize(buf, 800);
out.toUpperCase(); // also fine, apparently

Nothing in your build output changes. No warning, no new diagnostic, no deprecation notice. You get a green CI run and a slightly less safe program, and the blast radius is however many dependencies happened to lean on ambient Node types.

Finding it in your own repo

Three things I'd run before trusting a 6.0 upgrade.

Check what's actually loaded. tsc --showConfig prints the resolved config, so you can confirm types is what you think it is after all your extends chains flatten out:

npx tsc --showConfig | jq '.compilerOptions.types'

Then flip skipLibCheck off for exactly one run. Don't commit it, just see what falls out:

npx tsc --noEmit --skipLibCheck false 2>&1 | grep -E "TS2304|TS2318|TS2503"

TS2304 is a missing name, TS2318 is a missing global type like Array or Promise, and TS2503 is a missing namespace, usually NodeJS. If those show up with paths pointing into node_modules, you've found dependencies whose types are currently resolving to any in your build. You'll also get unrelated noise from genuinely broken third party typings, which is why you turned the flag on in the first place. Read the file paths, ignore the rest.

Last one, --explainFiles tells you why each file is in the program, which is the fastest way to see whether a type package is being included and by whom:

npx tsc --noEmit --explainFiles | grep -A1 "@types"

What I'd settle on

Explicit types per package, no ["*"] left in the tree after the migration week. Keep skipLibCheck on, because the alternative is worse, but accept that you've traded a class of error for a class of silence and make the no-skipLibCheck run part of your upgrade checklist rather than a thing you remember to do.

The change itself is correct. Global type pollution across an entire program was never a good default, and the explicit list is better. It's just that the migration guides all stop at Cannot find name 'process', and the compile that stays green is doing more damage than the one that turns red.