Skip to content

Commit 6ac84d3

Browse files
committed
Fix spec types test compatibility after upstream merge
Added FixSpecServerCapabilities and FixSpecInitializeResult type helpers to handle index signature requirements for ServerCapabilities that differ between the spec types (no index signature) and SDK types (passthrough with index signature).
1 parent e4c2695 commit 6ac84d3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/spec.types.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ type FixSpecClientCapabilities<T> = T extends { elicitation?: object }
6767
? Omit<T, 'elicitation'> & { elicitation?: Record<string, unknown> }
6868
: T;
6969

70+
// Targeted fix: in spec, ServerCapabilities needs index signature to match SDK's passthrough
71+
type FixSpecServerCapabilities<T> = T & { [x: string]: unknown };
72+
73+
type FixSpecInitializeResult<T> = T extends { capabilities: infer C }
74+
? T & { capabilities: FixSpecServerCapabilities<C> }
75+
: T;
76+
7077
type FixSpecInitializeRequestParams<T> = T extends { capabilities: infer C }
7178
? Omit<T, 'capabilities'> & { capabilities: FixSpecClientCapabilities<C> }
7279
: T;
@@ -531,15 +538,15 @@ const sdkTypeChecks = {
531538
sdk = spec;
532539
spec = sdk;
533540
},
534-
InitializeResult: (sdk: SDKTypes.InitializeResult, spec: SpecTypes.InitializeResult) => {
541+
InitializeResult: (sdk: SDKTypes.InitializeResult, spec: FixSpecInitializeResult<SpecTypes.InitializeResult>) => {
535542
sdk = spec;
536543
spec = sdk;
537544
},
538545
ClientCapabilities: (sdk: SDKTypes.ClientCapabilities, spec: FixSpecClientCapabilities<SpecTypes.ClientCapabilities>) => {
539546
sdk = spec;
540547
spec = sdk;
541548
},
542-
ServerCapabilities: (sdk: SDKTypes.ServerCapabilities, spec: SpecTypes.ServerCapabilities) => {
549+
ServerCapabilities: (sdk: SDKTypes.ServerCapabilities, spec: FixSpecServerCapabilities<SpecTypes.ServerCapabilities>) => {
543550
sdk = spec;
544551
spec = sdk;
545552
},

0 commit comments

Comments
 (0)