Repository navigation
[v1.x] fix(shared): stop referencing the DOM-only global HeadersInit in normalizeHeaders - #2807
nikolas-sapa wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: b606294 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
59ba89a to
88d7af0
Compare
|
Rebased onto the current While rebase-conflicting I reworked the branch to be a single commit, and dropped some noise that had crept in across the previous rebase attempts:
The diff against I confirmed the fix is still needed on the current tip — On a maintenance branch specifically, this seemed like the low-risk shape of v1.x change:
Checks: One thing I deliberately left alone: |
88d7af0 to
0a76b73
Compare
|
Two corrections to my earlier comment on this PR, plus a rebase. The rebase. My previous message said this was rebased onto the I also added the The red check was not this PR. 6m31s wall against a 300s undici headers timeout, in the publish step only. In the same job Still needed, and confirmed still needed. On the Verified on the rebased head:
|
…in normalizeHeaders
0a76b73 to
b606294
Compare
|
Rebased onto the current Base branch re-confirmed as Worth noting because it is easy to miss: upstream's 4 new commits include #2814, which edits the same file ( Verified on the rebased head (npm, matching CI's
The fix is still load-bearing, and I corrected how I proved it. My previous verification reported "the base tip fails with Re-run with
And I added a positive control — CI on the new head is green: Pushed with I am not going to claim this stays off |
|
Verification run for this PR. Confirmed the base is The fix is load-bearing — verified with a control that failsThe claim is that the published declaration references I built the package and compiled a minimal Node-only consumer against the emitted A) This branch (fixed): Emitted declaration: export declare function normalizeHeaders(headers: RequestInit['headers'] | undefined): Record<string, string>;
B) Control — same consumer against the pre-fix declaration (the only edit being the type annotation, reverted and rebuilt): export declare function normalizeHeaders(headers: HeadersInit | undefined): Record<string, string>;That is exactly the Build / test output
The one failure is This failure is pre-existing and unrelated. Control — reverting only
The pre-fix baseline fails more of that file, and the file contains no reference to Note on scopeThe change is type-only: it alters a published |
Summary
Fixes #2568 (marked
ready for work).shared/transport.d.tsexportsnormalizeHeaders(headers: HeadersInit | undefined).HeadersInitis a web-IDL type alias that@types/nodestructurally cannot bind globally — it bindsHeaders/Request/RequestInit/Responsefromundici-types, but atypedefcannot be declaration-merged the way the interface-shaped ones can (see the DefinitelyTyped PR #74414 review noted in the issue). So Node-only consumers compiling with"lib": ["ES2023"],"types": ["node"],"skipLibCheck": falsefail on the published declaration:This changes the signature to
RequestInit['headers'] | undefined— same-behaviour, dependent only on a global@types/nodedoes bind, and exactly what the v2 rewrite already does (#1279). Runtime code is unchanged. This is the 1.x backport the issue asks for (v2 is outside the peer range@anthropic-ai/claude-agent-sdkpins).Verification
Consumer repro (
lib: ["ES2023"],types: ["node"],moduleResolution: "bundler",skipLibCheck: false, importingclient/index.jsandshared/transport.js):@modelcontextprotocol/sdk@1.30.0from npm:dist/esm/shared/transport.d.ts(7,51): error TS2304: Cannot find name 'HeadersInit'.— exactly the issue's errordist/esm:tsc --noEmitexits 0, including passing aHeadersinstance and tuple arrays throughnormalizeHeadersRepo typecheck error set is byte-identical with and without this change (verified by diffing
tsgo --noEmitoutput on the clean tree vs the fix — the 8 pre-existing errors are unrelated test-file drift in this environment).Type of change
Checklist
@modelcontextprotocol/sdk: patch)