fix(toRef): ref created from union typed prop can't be used in watch (#3048)

This commit is contained in:
07akioni
2021-02-04 02:12:51 +08:00
committed by GitHub
parent 6d5b623512
commit 4ca4666d58
2 changed files with 11 additions and 2 deletions

View File

@@ -9,7 +9,8 @@ import {
proxyRefs,
toRef,
toRefs,
ToRefs
ToRefs,
watch
} from './index'
function plainType(arg: number | Ref<number>) {
@@ -165,6 +166,14 @@ const obj = {
expectType<Ref<number>>(toRef(obj, 'a'))
expectType<Ref<number>>(toRef(obj, 'b'))
const objWithUnionProp: { a: string | number } = {
a: 1
}
watch(toRef(objWithUnionProp, 'a'), value => {
expectType<string | number>(value)
})
// toRefs
const objRefs = toRefs(obj)
expectType<{