Skip to content

Commit

Permalink
types(watch): watch array callback params type tuples (#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
a145789 committed Mar 7, 2022
1 parent a492aa6 commit 8fb7343
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/apis/watch.ts
Expand Up @@ -424,7 +424,7 @@ export function watch<
T extends Readonly<WatchSource<unknown>[]>,
Immediate extends Readonly<boolean> = false
>(
sources: T,
sources: [...T],
cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>,
options?: WatchOptions<Immediate>
): WatchStopHandle
Expand Down
4 changes: 2 additions & 2 deletions test-dts/watch.test-d.tsx
Expand Up @@ -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<Readonly<[string, string, number]>>(values)
expectType<Readonly<[string, string, number]>>(oldValues)
})
Expand All @@ -42,7 +42,7 @@ watch(

// const array
watch(
[source, source2, source3] as const,
[source, source2, source3],
(values, oldValues) => {
expectType<Readonly<[string, string, number]>>(values)
expectType<
Expand Down
2 changes: 1 addition & 1 deletion test/v3/runtime-core/apiWatch.spec.ts
Expand Up @@ -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
Expand Down

0 comments on commit 8fb7343

Please sign in to comment.