diff --git a/packages/array-random/index.d.ts b/packages/array-random/index.d.ts index e477b77b5..53d2ea7bf 100644 --- a/packages/array-random/index.d.ts +++ b/packages/array-random/index.d.ts @@ -1,3 +1,3 @@ declare function random(arr: [Head, ...Rest[]]): Head | Rest; -declare function random(arr: T[]): T | undefined; +declare function random(arr: readonly T[]): T | undefined; export default random; diff --git a/packages/array-random/index.tests.ts b/packages/array-random/index.tests.ts index 5b02d6ca5..e6871b794 100644 --- a/packages/array-random/index.tests.ts +++ b/packages/array-random/index.tests.ts @@ -7,6 +7,8 @@ const test3: number = random([1, 2, 3]); const test4: number | string = random([1, 2, "a"]); const numbers: number[] = []; const test5: number | undefined = random(numbers); +const readonlyNumbers: readonly number[] = [1, 2, 3]; +const test6: number | undefined = random(readonlyNumbers); // Not OK // @ts-expect-error