TS2688 / global type errors after adding "types": [] to tsconfig.json

Typescript·Sep 13, 2026·intermediate·
Quick answer

Setting `"types": []` (now common with TypeScript 6.0+'s stricter defaults) stops TypeScript from automatically including every @types/* package in node_modules as a global — which also silently drops packages like @types/node that your code actually relies on globally (like `process`, `Buffer`). List the global type packages you need explicitly in the `types` array.

What causes this error

By default, TypeScript automatically includes every package under @types/* in node_modules as ambient global types. That's convenient but also unpredictable — installing an unrelated `@types` package for a dev tool can silently leak globals into your app code. Setting `"types": []` opts out of the automatic inclusion entirely, which is safer, but if you actually needed one of those packages (most commonly `@types/node` for `process`, `Buffer`, `__dirname`), it now has to be listed explicitly or those globals disappear.

The Fix

// tsconfig.json — types: [] with nothing needed re-added
{
  "compilerOptions": {
    "types": [] // process, Buffer, etc. are now gone — TS2304 Cannot find name 'process'
  }
}

// Fix — explicitly list the global type packages your code actually uses
{
  "compilerOptions": {
    "types": ["node"]
  }
}

Common causes / variations

  • Adopting TypeScript 6.0's stricter recommended defaults without auditing which globals the codebase actually depends on
  • A codebase mixing browser and Node code that needs different `types` entries per `tsconfig.json` (e.g. one for the server, one for the client)
  • A testing framework's global types (`jest`, `vitest`) disappearing from test files after the same change

Related errors

See also: TypeScript 6.0 strict by default, Cannot find module or its type declarations.

Was this fix helpful?

Comments

Loading comments...