You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make spec type tests catch .optional() missing args too #1298
Added 151 compile-time key-parity assertions using three utility types:
KnownKeys<T> — strips index signatures, keeping only named keys
AssertExactKeys<A, B> — resolves to true when key sets match; produces a descriptive error type on mismatch
Assert<T extends true> — forces a compile error on mismatch
Every sdkTypeChecks entry now has a corresponding assertion that fails at pnpm typecheck time if the SDK type has extra or missing keys relative to the spec.
Coverage: 151 of 174 entries. 23 excluded with documentation (15 union types where key enumeration isn't meaningful, 8 primitive aliases).
Discovered mismatches
The new assertions immediately caught 7 genuine SDK/spec key differences:
SDK Type
Issue
PromptReference
Missing title from spec
Resource
Missing size from spec
PromptArgument
Missing title from spec
ResourceLink
Missing size from spec
ClientCapabilities
Missing extensions from spec
ServerCapabilities
Missing extensions from spec
RequestMetaObject
Extra io.modelcontextprotocol/related-task not in spec
These are documented with @ts-expect-error — when the SDK catches up, the directive itself errors, prompting removal.
Activity
test: add compile-time key-parity assertions for spec type checks
rechedev9 commentedon Mar 9, 2026
I've implemented a solution for this in PR #1652.
Approach
Added 151 compile-time key-parity assertions using three utility types:
KnownKeys<T>— strips index signatures, keeping only named keysAssertExactKeys<A, B>— resolves totruewhen key sets match; produces a descriptive error type on mismatchAssert<T extends true>— forces a compile error on mismatchEvery
sdkTypeChecksentry now has a corresponding assertion that fails atpnpm typechecktime if the SDK type has extra or missing keys relative to the spec.Coverage: 151 of 174 entries. 23 excluded with documentation (15 union types where key enumeration isn't meaningful, 8 primitive aliases).
Discovered mismatches
The new assertions immediately caught 7 genuine SDK/spec key differences:
PromptReferencetitlefrom specResourcesizefrom specPromptArgumenttitlefrom specResourceLinksizefrom specClientCapabilitiesextensionsfrom specServerCapabilitiesextensionsfrom specRequestMetaObjectio.modelcontextprotocol/related-tasknot in specThese are documented with
@ts-expect-error— when the SDK catches up, the directive itself errors, prompting removal.Zero runtime overhead. Single file changed.