@@ -210,10 +210,9 @@ test("IsOptional<T> - detects if type includes undefined", () => {
210210// =============================================================================
211211
212212test ( "ZagoraResult<...> - result type structure for success/error cases" , ( ) => {
213- type TestSchema1 = AnySchema ;
214213 type TestErrorsMap = {
215- validation : TestSchema1 ;
216- notFound : TestSchema1 ;
214+ NOT_VALID : AnySchema ;
215+ NOT_FOUND : AnySchema ;
217216 } ;
218217
219218 // Success result shape
@@ -240,7 +239,7 @@ test("ZagoraResult<...> - result type structure for success/error cases", () =>
240239 TestErrorsMap ,
241240 { readonly ok : true }
242241 > ;
243- expectTypeOf < SuccessWithErrorMap > ( ) . toMatchTypeOf < {
242+ expectTypeOf < SuccessWithErrorMap > ( ) . toEqualTypeOf < {
244243 readonly ok : true ;
245244 data : number ;
246245 readonly error : undefined ;
@@ -252,7 +251,7 @@ test("ZagoraResult<...> - result type structure for success/error cases", () =>
252251 TestErrorsMap ,
253252 { readonly ok : false }
254253 > ;
255- expectTypeOf < ErrorWithMap > ( ) . toMatchTypeOf < {
254+ expectTypeOf < ErrorWithMap > ( ) . toMatchObjectType < {
256255 readonly ok : false ;
257256 readonly isTypedError : true ;
258257 } > ( ) ;
@@ -308,15 +307,15 @@ test("ResolveProcedure<...> - handler function signature based on disableOptions
308307
309308 // With disableOptions = true, no input schema
310309 type Proc1 = ResolveProcedure < true , TestContext , undefined , undefined > ;
311- expectTypeOf < Proc1 > ( ) . toMatchTypeOf < ( ) => any > ( ) ;
310+ expectTypeOf < Proc1 > ( ) . toEqualTypeOf < ( ) => any > ( ) ;
312311
313312 // With disableOptions = true, single input schema
314313 type Proc2 = ResolveProcedure < true , TestContext , StringSchema , undefined > ;
315- expectTypeOf < Proc2 > ( ) . toMatchTypeOf < ( arg : string ) => any > ( ) ;
314+ expectTypeOf < Proc2 > ( ) . toExtend < ( arg : string ) => any > ( ) ;
316315
317316 // With disableOptions = false, no input schema
318317 type Proc3 = ResolveProcedure < false , TestContext , undefined , TestErrorsMap > ;
319- expectTypeOf < Proc3 > ( ) . toMatchTypeOf <
318+ expectTypeOf < Proc3 > ( ) . toEqualTypeOf <
320319 ( options : ResolveHandlerOptions < TestContext , TestErrorsMap > ) => any
321320 > ( ) ;
322321
@@ -327,7 +326,7 @@ test("ResolveProcedure<...> - handler function signature based on disableOptions
327326 StringSchema ,
328327 TestErrorsMap
329328 > ;
330- expectTypeOf < Proc4 > ( ) . toMatchTypeOf <
329+ expectTypeOf < Proc4 > ( ) . toExtend <
331330 (
332331 options : ResolveHandlerOptions < TestContext , TestErrorsMap > ,
333332 arg : string ,
@@ -342,24 +341,24 @@ test("ResolveProcedure<...> - handler function signature based on disableOptions
342341test ( "SpreadTuple<T, R> - spreads tuple types into function parameters with optional handling" , ( ) => {
343342 // Single element tuple
344343 type Spread1 = SpreadTuple < readonly [ string ] , number > ;
345- expectTypeOf < Spread1 > ( ) . toMatchTypeOf < ( arg : string ) => number > ( ) ;
344+ expectTypeOf < Spread1 > ( ) . toEqualTypeOf < ( arg : string ) => number > ( ) ;
346345
347346 // Two element tuple (both required)
348347 type Spread2 = SpreadTuple < readonly [ string , number ] , boolean > ;
349- expectTypeOf < Spread2 > ( ) . toMatchTypeOf <
348+ expectTypeOf < Spread2 > ( ) . toEqualTypeOf <
350349 ( ( arg1 : string , arg2 : number ) => boolean ) | ( ( arg1 : string ) => boolean )
351350 > ( ) ;
352351
353352 // Two element tuple (second optional)
354353 type Spread3 = SpreadTuple < readonly [ string , number | undefined ] , boolean > ;
355- expectTypeOf < Spread3 > ( ) . toMatchTypeOf <
354+ expectTypeOf < Spread3 > ( ) . toEqualTypeOf <
356355 | ( ( arg1 : string , arg2 ?: number | undefined ) => boolean )
357356 | ( ( arg1 : string ) => boolean )
358357 > ( ) ;
359358
360359 // Three element tuple (all required)
361360 type Spread4 = SpreadTuple < readonly [ string , number , boolean ] , void > ;
362- expectTypeOf < Spread4 > ( ) . toMatchTypeOf <
361+ expectTypeOf < Spread4 > ( ) . toEqualTypeOf <
363362 | ( ( arg1 : string , arg2 : number , arg3 : boolean ) => void )
364363 | ( ( arg1 : string , arg2 : number ) => void )
365364 | ( ( arg1 : string ) => void )
@@ -370,22 +369,22 @@ test("SpreadTuple<T, R> - spreads tuple types into function parameters with opti
370369 readonly [ string , number , boolean | undefined ] ,
371370 void
372371 > ;
373- expectTypeOf < Spread5 > ( ) . toMatchTypeOf <
372+ expectTypeOf < Spread5 > ( ) . toEqualTypeOf <
374373 | ( ( arg1 : string , arg2 : number , arg3 ?: boolean | undefined ) => void )
375374 | ( ( arg1 : string , arg2 : number ) => void )
376375 | ( ( arg1 : string ) => void )
377376 > ( ) ;
378377
379378 // Empty tuple
380379 type Spread6 = SpreadTuple < readonly [ ] , string > ;
381- expectTypeOf < Spread6 > ( ) . toMatchTypeOf < ( ) => string > ( ) ;
380+ expectTypeOf < Spread6 > ( ) . toEqualTypeOf < ( ) => string > ( ) ;
382381
383382 // Many element tuple (rest parameter)
384383 type Spread7 = SpreadTuple <
385384 readonly [ string , number , boolean , object , symbol ] ,
386385 any
387386 > ;
388- expectTypeOf < Spread7 > ( ) . toMatchTypeOf <
387+ expectTypeOf < Spread7 > ( ) . toEqualTypeOf <
389388 ( ...args : readonly [ string , number , boolean , object , symbol ] ) => any
390389 > ( ) ;
391390} ) ;
@@ -418,18 +417,18 @@ test("Function parameters - createResult, validateInputOutput, validateError sig
418417 // Test validateInputOutput parameters
419418 // validateInputOutput(mode: "input" | "output", schema: any, data: any)
420419 type ValidateInputOutputFn = typeof validateInputOutput ;
421- expectTypeOf < ValidateInputOutputFn > ( ) . toMatchTypeOf <
420+ expectTypeOf < ValidateInputOutputFn > ( ) . toExtend <
422421 ( mode : "input" | "output" , schema : any , data : any ) => any
423422 > ( ) ;
424423
425- expectTypeOf < ValidateInputOutputFn > ( ) . parameters . toMatchTypeOf <
424+ expectTypeOf < ValidateInputOutputFn > ( ) . parameters . toEqualTypeOf <
426425 [ "input" | "output" , any , any ]
427426 > ( ) ;
428427
429428 // Test validateError parameters
430429 // validateError<TKindNames>(errorsMap: Record<string, AnySchema>, error: any, isAsync: boolean)
431430 type ValidateErrorFn = typeof validateError ;
432- expectTypeOf < ValidateErrorFn > ( ) . toMatchTypeOf <
431+ expectTypeOf < ValidateErrorFn > ( ) . toExtend <
433432 < _TKindNames > (
434433 errorsMap : Record < string , AnySchema > ,
435434 error : any ,
@@ -439,16 +438,31 @@ test("Function parameters - createResult, validateInputOutput, validateError sig
439438
440439 // Test with specific error map type
441440 type SpecificErrorMap = {
442- notFound : AnySchema ;
443- unauthorized : AnySchema ;
441+ NOT_FOUND : AnySchema ;
442+ UNAUTHORIZED : AnySchema ;
444443 } ;
445444 const testValidateError = validateError < keyof SpecificErrorMap > (
446445 { } as SpecificErrorMap ,
447- { kind : "notFound " } ,
446+ { kind : "NOT_FOUND " } ,
448447 false ,
449448 ) ;
449+
450+ type Res =
451+ | {
452+ readonly ok : false ;
453+ readonly isTypedError : boolean ;
454+ readonly error : any ;
455+ readonly data ?: undefined ;
456+ }
457+ | {
458+ readonly ok : true ;
459+ readonly data : any ;
460+ readonly isTypedError ?: undefined ;
461+ readonly error ?: undefined ;
462+ } ;
463+
450464 // validateError returns a result object or a Promise of result object
451- expectTypeOf ( testValidateError ) . toMatchTypeOf < any > ( ) ;
465+ expectTypeOf ( testValidateError ) . toExtend < Res | Promise < Res > > ( ) ;
452466} ) ;
453467
454468// =============================================================================
@@ -510,7 +524,7 @@ test("Zagora procedures - sync handler return types", () => {
510524 expectTypeOf ( syncProc ) . toBeCallableWith ( "foo" , { name : "World" } ) ;
511525
512526 const syncResult = syncProc ( "foo" , { name : "World" } ) ;
513- expectTypeOf ( syncResult ) . toMatchTypeOf < ZagoraResult < any , any , any > > ( ) ;
527+ expectTypeOf ( syncResult ) . toExtend < ZagoraResult < any , any , any > > ( ) ;
514528
515529 if ( syncResult . error ) {
516530 expectTypeOf ( syncResult . ok ) . toEqualTypeOf < false > ( ) ;
@@ -561,9 +575,7 @@ test("Zagora procedures - async handler return types", async () => {
561575 . callable ( ) ;
562576
563577 const res1promise = safeAsyncParse ( ) ;
564- expectTypeOf ( res1promise ) . toMatchTypeOf <
565- Promise < ZagoraResult < any , any , any > >
566- > ( ) ;
578+ expectTypeOf ( res1promise ) . toExtend < Promise < ZagoraResult < any , any , any > > > ( ) ;
567579
568580 type ErrorKinds = InternalError [ "kind" ] | ValidationError [ "kind" ] ;
569581
0 commit comments