mirror of
https://github.com/honojs/hono.git
synced 2024-11-21 18:18:57 +01:00
fix(types): handle readonly array correctly (#3172)
This commit is contained in:
parent
a285c4b3b4
commit
bb14b1e5ba
@ -101,6 +101,11 @@ describe('JSONParsed', () => {
|
||||
type Expected = (number | null)[]
|
||||
expectTypeOf<Actual>().toEqualTypeOf<Expected>()
|
||||
})
|
||||
it('should convert { key: readonly T[]} correctly', () => {
|
||||
type Actual = JSONParsed<{ key: readonly number[] }>
|
||||
type Expected = { key: readonly number[] }
|
||||
expectTypeOf<Actual>().toEqualTypeOf<Expected>()
|
||||
})
|
||||
})
|
||||
|
||||
describe('tuple', () => {
|
||||
|
@ -56,6 +56,8 @@ export type JSONParsed<T> = T extends { toJSON(): infer J }
|
||||
? [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 Set<unknown> | Map<unknown, unknown>
|
||||
? {}
|
||||
: T extends object
|
||||
|
Loading…
Reference in New Issue
Block a user