diff --git a/src/utils/types.test.ts b/src/utils/types.test.ts index 709ea6896..80fca294d 100644 --- a/src/utils/types.test.ts +++ b/src/utils/types.test.ts @@ -101,6 +101,11 @@ describe('JSONParsed', () => { type Expected = (number | null)[] expectTypeOf().toEqualTypeOf() }) + it('should convert { key: readonly T[]} correctly', () => { + type Actual = JSONParsed<{ key: readonly number[] }> + type Expected = { key: readonly number[] } + expectTypeOf().toEqualTypeOf() + }) }) describe('tuple', () => { diff --git a/src/utils/types.ts b/src/utils/types.ts index 8beb970a6..3fd17a949 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -56,6 +56,8 @@ export type JSONParsed = T extends { toJSON(): infer J } ? [JSONParsed>, ...JSONParsed] : T extends Array ? Array>> + : T extends ReadonlyArray + ? ReadonlyArray>> : T extends Set | Map ? {} : T extends object