File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ type FilterKeys<TObj extends object, TFilter> = {
28
28
// prettier-ignore
29
29
export type Serialize < T > =
30
30
IsAny < T > extends true ? any :
31
- T extends JsonPrimitive ? T :
31
+ T extends JsonPrimitive | undefined ? T :
32
32
T extends Map < any , any > | Set < any > ? Record < string , never > :
33
33
T extends NonJsonPrimitive ? never :
34
34
T extends { toJSON ( ) : infer U } ? U :
Original file line number Diff line number Diff line change @@ -311,7 +311,14 @@ describe("defineCachedEventHandler", () => {
311
311
312
312
describe ( "type helpers" , ( ) => {
313
313
it ( "Serialize" , ( ) => {
314
+ expectTypeOf < Serialize < undefined > > ( ) . toEqualTypeOf < undefined > ( ) ;
315
+ expectTypeOf < Serialize < { test ?: string } > > ( ) . toEqualTypeOf < {
316
+ test ?: string ;
317
+ } > ( ) ;
314
318
expectTypeOf < Serialize < { test : Date } > > ( ) . toEqualTypeOf < { test : string } > ( ) ;
319
+ expectTypeOf < Serialize < { test ?: Date } > > ( ) . toEqualTypeOf < {
320
+ test ?: string ;
321
+ } > ( ) ;
315
322
expectTypeOf < Serialize < { test : Map < string , string > } > > ( ) . toEqualTypeOf < {
316
323
test : Record < string , never > ;
317
324
} > ( ) ;
You can’t perform that action at this time.
0 commit comments