$options: Options & MergedComponentOptionsOverride
$forceUpdate: () => void
$nextTick: typeof nextTick
- $watch(
- source: string | Function,
- cb: Function,
+ $watch<T extends string | ((...args: any) => any)>(
+ source: T,
+ cb: T extends (...args: any) => infer R
+ ? (...args: [R, R]) => any
+ : (...args: any) => any,
options?: WatchOptions
): WatchStopHandle
} & P &
-import { ref, computed, watch, expectType } from './index'
+import { ref, computed, watch, expectType, defineComponent } from './index'
const source = ref('foo')
const source2 = computed(() => source.value)
// no type error
console.log(value2.a)
})
+
+// #6135
+defineComponent({
+ data() {
+ return { a: 1 }
+ },
+ created() {
+ this.$watch(
+ () => this.a,
+ (v, ov) => {
+ expectType<number>(v)
+ expectType<number>(ov)
+ }
+ )
+ }
+})