Skip to content

Commit 8d1710f

Browse files
pawsongkolodny
authored andcommitted
fix typings about $push and $unshift command (#113)
1 parent 53bdb4c commit 8d1710f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export type Spec<T, C extends CustomCommands<object> = never> =
4949
| (C extends CustomCommands<infer O> ? O : never);
5050

5151
type ArraySpec<T, C extends CustomCommands<object>> =
52-
| { $push: T }
53-
| { $unshift: T }
52+
| { $push: T[] }
53+
| { $unshift: T[] }
5454
| { $splice: Array<[number] | [number, number] | [number, number, T]> }
5555
| { [index: string]: Spec<T, C> }; // Note that this does not type check properly if index: number.
5656

typings-test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,28 +207,28 @@ update(o, {
207207
// $ExpectType TestObject
208208
update(o, {
209209
array: {
210-
$push: "string"
210+
$push: ["string"]
211211
}
212212
});
213213

214214
// $ExpectError
215215
update(o, {
216216
array: {
217-
$push: 1
217+
$push: [1]
218218
}
219219
});
220220

221221
// $ExpectType TestObject
222222
update(o, {
223223
array: {
224-
$unshift: "string"
224+
$unshift: ["string"]
225225
}
226226
});
227227

228228
// $ExpectError
229229
update(o, {
230230
array: {
231-
$unshift: 1
231+
$unshift: [1]
232232
}
233233
});
234234

@@ -493,7 +493,7 @@ update(o, {
493493
// $ExpectType TestObject
494494
update(o, {
495495
intersection: {
496-
$unshift: "string"
496+
$unshift: ["string"]
497497
}
498498
});
499499

0 commit comments

Comments
 (0)