Repository navigation
Conversation
The exported signature referenced the bare global HeadersInit, which is
declared by the DOM lib only. Node-only consumers that compile with
"lib": ["ES2023"], "types": ["node"] and skipLibCheck: false failed
with TS2304 on the emitted dist/{esm,cjs}/shared/transport.d.ts.
RequestInit is also provided globally by @types/node via undici-types, so
its indexed access type resolves without DOM. This matches the signature
already shipped on main.
Refs modelcontextprotocol#2568
🦋 Changeset detectedLatest commit: 9cfb5d7 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: |
|
Read c2dae37 and grepped Two small things:
|
|
Thanks — that grep is the check I should have run myself, and it is reassuring that the two locals in
|
|
A follow-up PR is the right call; this one stays a one-line type fix that is easy to review, and I have nothing further on it. For the fixture, the cheapest version I can think of is a tiny consumer file that imports the built |
|
A step in the existing I prepared it as a stacked branch ( Verified both directions: with the |
|
Good, that covers both directions. One thing to settle in the follow-up: |
|
It uses the repo's own That means a dependency bump is the only thing that can move it, and if it does, the red step shows up in that bump PR, which is where someone should be looking anyway. I would rather keep that than pin a second copy of
|
|
Agreed, a red step in the bump PR is the right place for it, and one shared One thing about the "flip |
|
Not a one-off — you're right that without a control the fixture can go vacuous, so I added one to the stacked branch.
Verified the guard by simulating the drift — adding So |
|
Simulating the drift by adding One tightening: |
|
Tightened to match the whole diagnostic rather than the code alone: I left line and column out on purpose — they move whenever the file changes and would make the guard brittle — but the message ties it to the one name the control exists to test, so an unrelated "Cannot find name" no longer satisfies it. Checked all three outcomes:
The file stays a single identifier anyway, but the guard no longer depends on that being true. |
Problem
normalizeHeadersis exported with a bareHeadersInitparameter.HeadersInitis declared by the DOM lib only, so consumers that compile the SDK without DOM fail:RequestInitis declared globally by@types/node(viaundici-types) as well as by DOM, so indexing into it resolves in both environments.Change
This matches the signature already on
main(packages/core-internal/src/shared/transport.ts), so it is a v1 backport of the same shape rather than a new API decision.The
HeadersInitreferences left insrc/client/sse.tsandsrc/client/streamableHttp.tsare local variables and never reach the emitted declarations, so they are intentionally untouched to keep the diff minimal.Verification
Packed the branch and type-checked a consumer with
"lib": ["ES2023"],"types": ["node"],skipLibCheck: false:@modelcontextprotocol/sdk@1.30.0→TS2304(see issue)headers: RequestInit['headers']Also ran
npm run typecheck,eslint src/shared/transport.ts,prettier --check, andvitest run test/shared/transport.test.ts(50/50).A
patchchangeset is included.Fixes #2568