() => state.count,
(count, prevCount) => {
dummy = [count, prevCount]
+ // assert types
+ count + 1
+ prevCount + 1
}
)
await nextTick()
let dummy
watch(count, (count, prevCount) => {
dummy = [count, prevCount]
+ // assert types
+ count + 1
+ prevCount + 1
})
await nextTick()
expect(dummy).toMatchObject([0, undefined])
let dummy
watch(plus, (count, prevCount) => {
dummy = [count, prevCount]
+ // assert types
+ count + 1
+ prevCount + 1
})
await nextTick()
expect(dummy).toMatchObject([1, undefined])
let dummy
watch([() => state.count, count, plus], (vals, oldVals) => {
dummy = [vals, oldVals]
+ // assert types
+ vals.concat(1)
+ oldVals.concat(1)
})
await nextTick()
expect(dummy).toMatchObject([[1, 1, 2], []])
stop,
isRef,
Ref,
+ ComputedRef,
ReactiveEffectOptions
} from '@vue/reactivity'
import { queueJob } from './scheduler'
type StopHandle = () => void
-type WatcherSource<T = any> = Ref<T> | (() => T)
+type WatcherSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
type MapSources<T> = {
[K in keyof T]: T[K] extends WatcherSource<infer V> ? V : never