Skip to content

Commit 8fb7343

Browse files
authored
types(watch): watch array callback params type tuples (#912)
1 parent a492aa6 commit 8fb7343

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/apis/watch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ export function watch<
424424
T extends Readonly<WatchSource<unknown>[]>,
425425
Immediate extends Readonly<boolean> = false
426426
>(
427-
sources: T,
427+
sources: [...T],
428428
cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>,
429429
options?: WatchOptions<Immediate>
430430
): WatchStopHandle

test-dts/watch.test-d.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ watch([source, source2, source3], (values, oldValues) => {
1616
})
1717

1818
// const array
19-
watch([source, source2, source3] as const, (values, oldValues) => {
19+
watch([source, source2, source3], (values, oldValues) => {
2020
expectType<Readonly<[string, string, number]>>(values)
2121
expectType<Readonly<[string, string, number]>>(oldValues)
2222
})
@@ -42,7 +42,7 @@ watch(
4242

4343
// const array
4444
watch(
45-
[source, source2, source3] as const,
45+
[source, source2, source3],
4646
(values, oldValues) => {
4747
expectType<Readonly<[string, string, number]>>(values)
4848
expectType<

test/v3/runtime-core/apiWatch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ describe('api: watch', () => {
143143
const status = ref(false)
144144

145145
let dummy
146-
watch([() => state.count, status] as const, (vals, oldVals) => {
146+
watch([() => state.count, status], (vals, oldVals) => {
147147
dummy = [vals, oldVals]
148148
const [count] = vals
149149
const [, oldStatus] = oldVals

0 commit comments

Comments
 (0)