mirror of https://github.com/vuejs/core.git
parent
eab76046e3
commit
41d9c47300
|
@ -193,9 +193,11 @@ export type ComponentPublicInstance<
|
||||||
$options: Options & MergedComponentOptionsOverride
|
$options: Options & MergedComponentOptionsOverride
|
||||||
$forceUpdate: () => void
|
$forceUpdate: () => void
|
||||||
$nextTick: typeof nextTick
|
$nextTick: typeof nextTick
|
||||||
$watch(
|
$watch<T extends string | ((...args: any) => any)>(
|
||||||
source: string | Function,
|
source: T,
|
||||||
cb: Function,
|
cb: T extends (...args: any) => infer R
|
||||||
|
? (...args: [R, R]) => any
|
||||||
|
: (...args: any) => any,
|
||||||
options?: WatchOptions
|
options?: WatchOptions
|
||||||
): WatchStopHandle
|
): WatchStopHandle
|
||||||
} & P &
|
} & P &
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ref, computed, watch, expectType } from './index'
|
import { ref, computed, watch, expectType, defineComponent } from './index'
|
||||||
|
|
||||||
const source = ref('foo')
|
const source = ref('foo')
|
||||||
const source2 = computed(() => source.value)
|
const source2 = computed(() => source.value)
|
||||||
|
@ -75,3 +75,19 @@ watch([someRef, otherRef], values => {
|
||||||
// no type error
|
// no type error
|
||||||
console.log(value2.a)
|
console.log(value2.a)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #6135
|
||||||
|
defineComponent({
|
||||||
|
data() {
|
||||||
|
return { a: 1 }
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.$watch(
|
||||||
|
() => this.a,
|
||||||
|
(v, ov) => {
|
||||||
|
expectType<number>(v)
|
||||||
|
expectType<number>(ov)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue