From 8fb7343dddeb63a4401067a65979b0f7de9f7e07 Mon Sep 17 00:00:00 2001 From: clencat <37403253+a145789@users.noreply.github.com> Date: Mon, 7 Mar 2022 20:33:35 +0800 Subject: [PATCH] types(watch): watch array callback params type tuples (#912) --- src/apis/watch.ts | 2 +- test-dts/watch.test-d.tsx | 4 ++-- test/v3/runtime-core/apiWatch.spec.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apis/watch.ts b/src/apis/watch.ts index 517e78cf..b3e0984c 100644 --- a/src/apis/watch.ts +++ b/src/apis/watch.ts @@ -424,7 +424,7 @@ export function watch< T extends Readonly[]>, Immediate extends Readonly = false >( - sources: T, + sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchOptions ): WatchStopHandle diff --git a/test-dts/watch.test-d.tsx b/test-dts/watch.test-d.tsx index 946e2f92..2811743c 100644 --- a/test-dts/watch.test-d.tsx +++ b/test-dts/watch.test-d.tsx @@ -16,7 +16,7 @@ watch([source, source2, source3], (values, oldValues) => { }) // const array -watch([source, source2, source3] as const, (values, oldValues) => { +watch([source, source2, source3], (values, oldValues) => { expectType>(values) expectType>(oldValues) }) @@ -42,7 +42,7 @@ watch( // const array watch( - [source, source2, source3] as const, + [source, source2, source3], (values, oldValues) => { expectType>(values) expectType< diff --git a/test/v3/runtime-core/apiWatch.spec.ts b/test/v3/runtime-core/apiWatch.spec.ts index 57dc6335..b6825e0f 100644 --- a/test/v3/runtime-core/apiWatch.spec.ts +++ b/test/v3/runtime-core/apiWatch.spec.ts @@ -143,7 +143,7 @@ describe('api: watch', () => { const status = ref(false) let dummy - watch([() => state.count, status] as const, (vals, oldVals) => { + watch([() => state.count, status], (vals, oldVals) => { dummy = [vals, oldVals] const [count] = vals const [, oldStatus] = oldVals