mirror of
https://github.com/honojs/hono.git
synced 2024-11-21 18:18:57 +01:00
perf(types): use homomorphic mapped type to reduce conditional branches (#3440)
This commit is contained in:
parent
1d8028a70d
commit
e1eb98d293
@ -52,14 +52,8 @@ export type JSONParsed<T> = T extends { toJSON(): infer J }
|
||||
? T
|
||||
: T extends InvalidJSONValue
|
||||
? never
|
||||
: T extends []
|
||||
? []
|
||||
: T extends readonly [infer R, ...infer U]
|
||||
? [JSONParsed<InvalidToNull<R>>, ...JSONParsed<U>]
|
||||
: T extends Array<infer U>
|
||||
? Array<JSONParsed<InvalidToNull<U>>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<JSONParsed<InvalidToNull<U>>>
|
||||
: T extends ReadonlyArray<unknown>
|
||||
? { [K in keyof T]: JSONParsed<InvalidToNull<T[K]>> }
|
||||
: T extends Set<unknown> | Map<unknown, unknown>
|
||||
? {}
|
||||
: T extends object
|
||||
|
Loading…
Reference in New Issue
Block a user