Skip to content

fix(types): align Response with DOM fetch types#4867

Open
theamodhshetty wants to merge 1 commit intonodejs:mainfrom
theamodhshetty:codex/fix-response-iterator-types
Open

fix(types): align Response with DOM fetch types#4867
theamodhshetty wants to merge 1 commit intonodejs:mainfrom
theamodhshetty:codex/fix-response-iterator-types

Conversation

@theamodhshetty
Copy link
Contributor

Summary

  • align SpecIterableIterator with the iterator-helper surface expected by modern DOM HeadersIterator types
  • add the missing File[Symbol.toStringTag] declaration on node:buffer so Response.formData() stays structurally compatible
  • add a tsd regression proving Undici Response is assignable to globalThis.Response

Why

Newer TypeScript DOM libs model Headers.entries()/keys()/values() as HeadersIterator, which includes iterator helper methods. Undici's SpecIterableIterator was missing that surface, so undici.Response could not be used where a standard Response type was expected. Once that was fixed, formData() still diverged because Node's buffer.File typing was missing the Symbol.toStringTag property that exists at runtime.

Tests

  • npm run test:typescript
  • npm run lint

Fixes #3639

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.14%. Comparing base (bfeacd0) to head (7d5ad97).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4867   +/-   ##
=======================================
  Coverage   93.14%   93.14%           
=======================================
  Files         109      109           
  Lines       34254    34254           
=======================================
  Hits        31905    31905           
  Misses       2349     2349           

☔ 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.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

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.

(types) undici.Response cannot be assigned to Response

3 participants