Skip to content

Commit 8ba5eea

Browse files
author
ben.durrant
committed
account for length edge case
1 parent 4e119df commit 8ba5eea

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

docs/usage/usage-with-typescript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default store
136136

137137
#### Using `Tuple` without `getDefaultMiddleware`
138138

139-
If you want to skip the usage of `getDefaultMiddleware` altogether, you are requred to use `Tuple` for type-safe creation of your `middleware` array. This class extends the default JavaScript `Array` type, only with modified typings for `.concat(...)` and the additional `.prepend(...)` method.
139+
If you want to skip the usage of `getDefaultMiddleware` altogether, you are required to use `Tuple` for type-safe creation of your `middleware` array. This class extends the default JavaScript `Array` type, only with modified typings for `.concat(...)` and the additional `.prepend(...)` method.
140140

141141
For example:
142142

packages/toolkit/src/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ export function find<T>(
4040
return undefined
4141
}
4242

43-
export class Tuple<Items extends ReadonlyArray<unknown>> extends Array<
43+
export class Tuple<Items extends ReadonlyArray<unknown> = []> extends Array<
4444
Items[number]
4545
> {
46-
constructor(...items: Items) {
46+
constructor(length: number)
47+
constructor(...items: Items)
48+
constructor(...items: any[]) {
4749
super(...items)
4850
Object.setPrototypeOf(this, Tuple.prototype)
4951
}

0 commit comments

Comments
 (0)