[v1.x] fix(shared): stop referencing the DOM-only global HeadersInit in normalizeHeaders - #2807
Open
nikolas-sapa wants to merge 4 commits into
Open
Conversation
…alizeHeaders shared/transport.d.ts exports normalizeHeaders(headers: HeadersInit | undefined), and HeadersInit is a web-IDL type alias that @types/node structurally cannot bind globally (it binds Headers/Request/RequestInit/Response, but not the HeadersInit typedef — see DefinitelyTyped PR #74414 review). Node-only consumers compiling with skipLibCheck: false and no "DOM" lib fail with TS2304: Cannot find name 'HeadersInit' (reported against 1.23.0-beta.0 through 1.30.0). Use RequestInit['headers'] instead — same-behaviour, and exactly what the v2 rewrite already does (modelcontextprotocol#1279). Runtime code is unchanged. Verified: a Node-only consumer (lib ES2023, types node, skipLibCheck false) fails with the reported TS2304 against @modelcontextprotocol/sdk@1.30.0 and typechecks clean against this branch's emitted declarations. Full repo typecheck error set is byte-identical with and without this change. Fixes modelcontextprotocol#2568
🦋 Changeset detectedLatest commit: cb54794 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)