@@ -24,7 +24,13 @@ import {
2424 CreateTaskResultSchema ,
2525 Tool ,
2626 Prompt ,
27- Resource
27+ Resource ,
28+ type Request ,
29+ type Notification ,
30+ type Result ,
31+ type RequestBase ,
32+ type NotificationBase ,
33+ type ResultBase
2834} from '../../src/types.js' ;
2935import { Transport } from '../../src/shared/transport.js' ;
3036import { Server } from '../../src/server/index.js' ;
@@ -75,6 +81,7 @@ describe('Zod v4', () => {
7581 type WeatherResult = z4 . infer < typeof WeatherResultSchema > ;
7682
7783 // Create a typed Client for weather data
84+ // @ts -expect-error Custom test types don't extend Request/Notification/Result unions
7885 const weatherClient = new Client < WeatherRequest , WeatherNotification , WeatherResult > (
7986 {
8087 name : 'WeatherClient' ,
@@ -156,6 +163,7 @@ describe('Zod v3', () => {
156163 type WeatherResult = z3 . infer < typeof WeatherResultSchema > ;
157164
158165 // Create a typed Client for weather data
166+ // @ts -expect-error Custom test types don't extend Request/Notification/Result unions
159167 const weatherClient = new Client < WeatherRequest , WeatherNotification , WeatherResult > (
160168 {
161169 name : 'WeatherClient' ,
@@ -211,7 +219,7 @@ test('should initialize with matching protocol version', async () => {
211219 version : '1.0'
212220 } ,
213221 instructions : 'test instructions'
214- }
222+ } as ResultBase
215223 } ) ;
216224 }
217225 return Promise . resolve ( ) ;
@@ -269,7 +277,7 @@ test('should initialize with supported older protocol version', async () => {
269277 name : 'test' ,
270278 version : '1.0'
271279 }
272- }
280+ } as ResultBase
273281 } ) ;
274282 }
275283 return Promise . resolve ( ) ;
@@ -319,7 +327,7 @@ test('should reject unsupported protocol version', async () => {
319327 name : 'test' ,
320328 version : '1.0'
321329 }
322- }
330+ } as ResultBase
323331 } ) ;
324332 }
325333 return Promise . resolve ( ) ;
@@ -885,7 +893,7 @@ test('should reject form-mode elicitation when client only supports URL mode', a
885893 name : 'test-server' ,
886894 version : '1.0.0'
887895 }
888- }
896+ } as ResultBase
889897 } ) ;
890898 } else if ( message . method === 'notifications/initialized' ) {
891899 // ignore
@@ -1030,7 +1038,7 @@ test('should reject URL-mode elicitation when client only supports form mode', a
10301038 name : 'test-server' ,
10311039 version : '1.0.0'
10321040 }
1033- }
1041+ } as ResultBase
10341042 } ) ;
10351043 } else if ( message . method === 'notifications/initialized' ) {
10361044 // ignore
@@ -2381,7 +2389,7 @@ describe('Task-based execution', () => {
23812389
23822390 const result = {
23832391 content : [ { type : 'text' , text : 'Tool executed successfully!' } ]
2384- } ;
2392+ } as ResultBase ;
23852393 await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
23862394
23872395 return { task } ;
@@ -2457,7 +2465,7 @@ describe('Task-based execution', () => {
24572465
24582466 const result = {
24592467 content : [ { type : 'text' , text : 'Success!' } ]
2460- } ;
2468+ } as ResultBase ;
24612469 await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
24622470
24632471 return { task } ;
@@ -2534,7 +2542,7 @@ describe('Task-based execution', () => {
25342542
25352543 const result = {
25362544 content : [ { type : 'text' , text : 'Result data!' } ]
2537- } ;
2545+ } as ResultBase ;
25382546 await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
25392547
25402548 return { task } ;
@@ -2615,7 +2623,7 @@ describe('Task-based execution', () => {
26152623
26162624 const result = {
26172625 content : [ { type : 'text' , text : 'Success!' } ]
2618- } ;
2626+ } as ResultBase ;
26192627 await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
26202628
26212629 return { task } ;
@@ -2707,7 +2715,7 @@ describe('Task-based execution', () => {
27072715
27082716 client . setRequestHandler ( ElicitRequestSchema , async ( request , extra ) => {
27092717 const result = {
2710- action : 'accept' ,
2718+ action : 'accept' as const ,
27112719 content : { username : 'list-user' }
27122720 } ;
27132721
@@ -2716,7 +2724,7 @@ describe('Task-based execution', () => {
27162724 const task = await extra . taskStore . createTask ( {
27172725 ttl : extra . taskRequestedTtl
27182726 } ) ;
2719- await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
2727+ await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result as ResultBase ) ;
27202728 // Return CreateTaskResult when task creation is requested
27212729 return { task } ;
27222730 }
@@ -2800,7 +2808,7 @@ describe('Task-based execution', () => {
28002808
28012809 client . setRequestHandler ( ElicitRequestSchema , async ( request , extra ) => {
28022810 const result = {
2803- action : 'accept' ,
2811+ action : 'accept' as const ,
28042812 content : { username : 'list-user' }
28052813 } ;
28062814
@@ -2809,7 +2817,7 @@ describe('Task-based execution', () => {
28092817 const task = await extra . taskStore . createTask ( {
28102818 ttl : extra . taskRequestedTtl
28112819 } ) ;
2812- await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
2820+ await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result as ResultBase ) ;
28132821 // Return CreateTaskResult when task creation is requested
28142822 return { task } ;
28152823 }
@@ -2892,7 +2900,7 @@ describe('Task-based execution', () => {
28922900
28932901 client . setRequestHandler ( ElicitRequestSchema , async ( request , extra ) => {
28942902 const result = {
2895- action : 'accept' ,
2903+ action : 'accept' as const ,
28962904 content : { username : 'result-user' }
28972905 } ;
28982906
@@ -2901,7 +2909,7 @@ describe('Task-based execution', () => {
29012909 const task = await extra . taskStore . createTask ( {
29022910 ttl : extra . taskRequestedTtl
29032911 } ) ;
2904- await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
2912+ await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result as ResultBase ) ;
29052913 // Return CreateTaskResult when task creation is requested
29062914 return { task } ;
29072915 }
@@ -2983,7 +2991,7 @@ describe('Task-based execution', () => {
29832991
29842992 client . setRequestHandler ( ElicitRequestSchema , async ( request , extra ) => {
29852993 const result = {
2986- action : 'accept' ,
2994+ action : 'accept' as const ,
29872995 content : { username : 'list-user' }
29882996 } ;
29892997
@@ -2992,7 +3000,7 @@ describe('Task-based execution', () => {
29923000 const task = await extra . taskStore . createTask ( {
29933001 ttl : extra . taskRequestedTtl
29943002 } ) ;
2995- await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
3003+ await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result as ResultBase ) ;
29963004 // Return CreateTaskResult when task creation is requested
29973005 return { task } ;
29983006 }
@@ -3100,7 +3108,7 @@ describe('Task-based execution', () => {
31003108
31013109 const result = {
31023110 content : [ { type : 'text' , text : `Result for ${ id || 'unknown' } ` } ]
3103- } ;
3111+ } as ResultBase ;
31043112 await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
31053113
31063114 return { task } ;
@@ -3368,7 +3376,7 @@ test('should respect server task capabilities', async () => {
33683376
33693377 const result = {
33703378 content : [ { type : 'text' , text : 'Success!' } ]
3371- } ;
3379+ } as ResultBase ;
33723380 await extra . taskStore . storeTaskResult ( task . taskId , 'completed' , result ) ;
33733381
33743382 return { task } ;
0 commit comments