Skip to content

Commit

Permalink
Add readonly array support to array-splitAt
Browse files Browse the repository at this point in the history
  • Loading branch information
Masa-Shin committed Apr 25, 2023
1 parent d0bac2f commit fef8e07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/array-split-at/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function splitAt<T>(arr: T[], n?: number | null): [T[], T[]]
export default function splitAt<T>(arr: readonly T[], n?: number | null): [T[], T[]]
5 changes: 4 additions & 1 deletion packages/array-split-at/index.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const test2: [number[], number[]] = splitAt([1, 2, 3, 4, 5], -1); // [[1, 2, 3,
const test3: [unknown[], unknown[]] = splitAt([], 3); // [[], []]
const test4: [boolean[], boolean[]] = splitAt([true, false]); // [[], [true, false]]

const readonlyArr: readonly number[] = [1, 2, 3]
splitAt(readonlyArr, 1)

// Not OK
// @ts-expect-error
splitAt()
Expand All @@ -18,4 +21,4 @@ splitAt([], true)
// @ts-expect-error
splitAt([], [])
// @ts-expect-error
splitAt([], 2, 3)
splitAt([], 2, 3)

0 comments on commit fef8e07

Please sign in to comment.