Skip to content

fix(check): load a single @types/node#35641

Merged
bartlomieju merged 1 commit into
mainfrom
feat/single-types-node
Jul 8, 2026
Merged

fix(check): load a single @types/node#35641
bartlomieju merged 1 commit into
mainfrom
feat/single-types-node

Conversation

@bartlomieju

@bartlomieju bartlomieju commented Jun 30, 2026

Copy link
Copy Markdown
Member

When a project provides its own @types/node, the type-checker loaded it
and the built-in copy that backs lib="node". With a single global symbol
table that means every node declaration (process, Buffer, node:path, the
Server / Console / etc. types) is declared twice. The current forked
compiler hides this with its dual node/deno global tables, but it's a latent
double-load and a blocker for moving to a single global table.

This resolves the user's @types/node once (from the project) and references
the resolved file directly from lib.node.d.ts, so exactly one copy ends up in
the program. When the project has no @types/node, the built-in copy is served
as before, so the default experience is unchanged.

The resolved path is referenced directly instead of re-emitting
/// <reference types="npm:@types/node" />, because the latter would be
re-resolved relative to the asset:///lib.node.d.ts file rather than the
project, which fails for cache-only / --frozen installs (the package is known
from the lockfile but not under node_modules).


Part of the broader effort to drop Deno's forked TypeScript; see #35621 for context and the overall plan.

When a project provides its own @types/node, the type-checker loaded both it and
the built-in copy, so with a single global symbol table every node declaration
is duplicated. Resolve the user's @types/node once and reference the resolved
file directly from lib.node.d.ts (so exactly one copy is in the program),
falling back to the built-in when the user has none. The resolved path is
referenced directly rather than re-emitting `types="npm:@types/node"`, which
would be re-resolved relative to the asset file and fail for cache-only / frozen
installs.
@bartlomieju
bartlomieju merged commit 1d4e6c1 into main Jul 8, 2026
137 checks passed
@bartlomieju
bartlomieju deleted the feat/single-types-node branch July 8, 2026 15:06
bartlomieju added a commit that referenced this pull request Jul 8, 2026
This drops Deno's forked TypeScript compiler and runs on stock
`[email protected]` from npm (the exact version the fork was based on).
The forked `cli/tsc/00_typescript.js` and its ~466-line patch set are
removed, along with the five `ts.deno.*` host hooks the fork exposed
(`setIsNodeSourceFileCallback`, `setNodeOnlyGlobalNames`,
`setTypesNodeIgnorableNames`, and the LSP span callbacks). Forking tsc
has meant a manual re-port of the patch set and a hand-rebuilt 9 MB bundle
on every upgrade; on stock TypeScript an upgrade becomes a version bump.

The fork's load-bearing patch was a dual node/deno global symbol table
in the checker. That is replaced by a pure `.d.ts` mechanism: Deno's libs
declare the marker globals (`onmessage`/`onabort`/`ReportingObserver`) that stock
`@types/node` probes for, so `@types/node` defers its web-platform
globals to Deno's exactly as it defers to `lib.dom`, and everything resolves
against a single global table. This builds on the prep PRs already merged: the
deferral transform (#35639), the `PerformanceObserver` types (#35640), and single
`@types/node` loading (#35641). It also carries the `URLPattern`
concession (`@types/node` declares it unconditionally, so Deno keeps only the
interface) and tightens `import.meta.dirname`/`filename` to required `string` to
match `@types/node`.

This is a breaking change and targets Deno 3. Five `check` specs are
temporarily disabled with `ignore: true` and a comment pointing at their
follow-ups: `check_workspace` and the marker interaction, the `export =`
declaration-file case, per-member `jsxImportSource`
(`jsx_import_source_different_per_member`), and transitive `@types/node`
(`express_with_koa`, re-enabled by #35871). The LSP runs on the same
stock compiler; its dedicated verification is still pending.

See #35621 for the full investigation and plan.

Fixes #33012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant