Skip to content

types: stop interfering with @types/node#5173

Merged
mcollina merged 1 commit into
nodejs:mainfrom
Renegade334:unfuck-types-node
May 4, 2026
Merged

types: stop interfering with @types/node#5173
mcollina merged 1 commit into
nodejs:mainfrom
Renegade334:unfuck-types-node

Conversation

@Renegade334

Copy link
Copy Markdown
Member

This was driven by some quirky nonsense whereby

  • undici's type definitions use the File interface defined by @types/node (which, like TypeScript's own web libraries, doesn't declare a toStringTag property)
  • within the repo itself, the project's devDependencies use @types/node 22.x, which depends on the outdated undici-types 6.21.0 from 2024
  • this version of undici-types is old enough to have had its own File implementation (which declared a toStringTag property)
  • in the tsd test environment, it's possible to accidentally unearth the File interface from the outdated undici-types, if it's resolved via a global fetch type rather than an imported one (since TS resolves the globals to the undici-types dependency in node_modules, not the local project)
  • it was noticed in the test environment that if one manages to observe this old undici-types File interface by deliberately targeting globalThis, then it's not assignable from the one used in the undici project itself (the @types/node one), due to the missing toStringTag property – even though this is a meaningless observation
  • the solution for this non-issue was to (breakingly) externally monkeypatch @types/node from undici, in order to make its File interface assignable to the one that no longer exists

Let's not do this again.

Refs: #4867 (comment)

Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk>
@codecov-commenter

codecov-commenter commented May 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.28%. Comparing base (e58fead) to head (56bc869).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5173   +/-   ##
=======================================
  Coverage   93.27%   93.28%           
=======================================
  Files         110      110           
  Lines       36243    36243           
=======================================
+ Hits        33807    33809    +2     
+ Misses       2436     2434    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KhafraDev KhafraDev requested a review from mcollina May 3, 2026 15:10

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 3d6f502 into nodejs:main May 4, 2026
35 checks passed
@Renegade334 Renegade334 deleted the unfuck-types-node branch May 4, 2026 08:58
@github-actions github-actions Bot mentioned this pull request May 14, 2026
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.

4 participants