File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ type FilterKeys<TObj extends object, TFilter> = {
2828// prettier-ignore
2929export type Serialize < T > =
3030 IsAny < T > extends true ? any :
31- T extends JsonPrimitive ? T :
31+ T extends JsonPrimitive | undefined ? T :
3232 T extends Map < any , any > | Set < any > ? Record < string , never > :
3333 T extends NonJsonPrimitive ? never :
3434 T extends { toJSON ( ) : infer U } ? U :
Original file line number Diff line number Diff line change @@ -311,7 +311,14 @@ describe("defineCachedEventHandler", () => {
311311
312312describe ( "type helpers" , ( ) => {
313313 it ( "Serialize" , ( ) => {
314+ expectTypeOf < Serialize < undefined > > ( ) . toEqualTypeOf < undefined > ( ) ;
315+ expectTypeOf < Serialize < { test ?: string } > > ( ) . toEqualTypeOf < {
316+ test ?: string ;
317+ } > ( ) ;
314318 expectTypeOf < Serialize < { test : Date } > > ( ) . toEqualTypeOf < { test : string } > ( ) ;
319+ expectTypeOf < Serialize < { test ?: Date } > > ( ) . toEqualTypeOf < {
320+ test ?: string ;
321+ } > ( ) ;
315322 expectTypeOf < Serialize < { test : Map < string , string > } > > ( ) . toEqualTypeOf < {
316323 test : Record < string , never > ;
317324 } > ( ) ;
You can’t perform that action at this time.
0 commit comments