diff --git a/types/react/next.d.ts b/types/react/next.d.ts index 81ccab1eadb27a..3e198deebd4c1d 100644 --- a/types/react/next.d.ts +++ b/types/react/next.d.ts @@ -55,7 +55,7 @@ declare module '.' { export function use(usable: Usable): T; - interface ServerContextJSONArray extends ReadonlyArray {} + interface ServerContextJSONArray extends ReadonlyArray {} export type ServerContextJSONValue = | string | boolean diff --git a/types/react/test/next.tsx b/types/react/test/next.tsx index 92e2bb7469178b..dfb600cd2d9dcd 100644 --- a/types/react/test/next.tsx +++ b/types/react/test/next.tsx @@ -42,6 +42,10 @@ function serverContextTest() { // plain objects work React.createServerContext('PlainObjectContext', { foo: 1 }); + // readonly arrays work + React.createServerContext('ReadonlyArrayContext', ['foo', 'bar'] as const); + // nested readonly arrays work + React.createServerContext('ReadonlyArrayContext', ['foo', ['bar']] as const); // @ts-expect-error Incompatible with JSON stringify+parse React.createServerContext('DateContext', new Date()); // @ts-expect-error Incompatible with JSON stringify+parse