Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add readonly array support to just-random #565

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/array-random/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare function random<Head, Rest>(arr: [Head, ...Rest[]]): Head | Rest;
declare function random<T>(arr: T[]): T | undefined;
declare function random<T>(arr: readonly T[]): T | undefined;
export default random;
2 changes: 2 additions & 0 deletions packages/array-random/index.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down