Skip to content

Declare @types/node explicitly per package and evaluate the TypeScript 7 migration #129

Description

@mingyooagi

Why

Dependabot's TypeScript 7 bump (#122) fails CI, and the failure is not a lockfile problem — it exposes a fragile assumption in how this workspace resolves Node types.

Evidence

Run 31101319325 dies while building @opentag/discord:

src/gateway.ts(1,28): error TS2591: Cannot find name 'node:crypto'.
src/gateway.ts(94,43): error TS2591: Cannot find name 'Buffer'.
src/gateway.ts(397,30): error TS2591: Cannot find name 'process'.
ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @opentag/discord@0.9.0 build

Root cause: @types/node is declared only in the root package.json, and no tsconfig sets types or typeRoots. Every workspace package therefore depends on TypeScript walking up from its own directory to the root node_modules/@types to find Node types. TypeScript 5.9 resolves it that way; TypeScript 7 does not in this pnpm workspace layout, so Node globals and node:* modules lose their types repo-wide.

@opentag/discord is simply the first package tsc -b reaches that imports a Node built-in, so any further TypeScript 7 breakage is still hidden behind this first failure.

Work

  1. Declare @types/node as an explicit devDependency in every package and app that uses Node built-ins (or set typeRoots/types in tsconfig.base.json), then confirm the current TypeScript 5.9 build still passes. This is worth doing on its own merit — depending on the root-hoisted @types/node is fragile regardless of TypeScript 7.
  2. Re-attempt the TypeScript 7 bump on top of that and triage whatever surfaces once the build gets past discord.
  3. Keep @types/node on the major matching the lowest Node version we support (^22 today, see #123). Revisit only when engines moves.

Notes

  • Dependabot now ignores semver-major updates for typescript and @types/node, so these bumps will not reappear automatically until we act.
  • engines is currently inconsistent: >=22.14.0 for @opentag/cli, dispatcher, store, and local-runtime, but >=20 for the other 11 packages, while CI only runs Node 22. Worth reconciling as part of step 3, since it determines which @types/node major is correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions