feat(reactivity): support default value in toRef()

This commit is contained in:
Evan You
2021-12-11 16:41:58 +08:00
parent d0ea900922
commit 2db9c909c2
3 changed files with 41 additions and 3 deletions

View File

@@ -224,6 +224,13 @@ expectType<Ref<string>>(p2.obj.k)
expectType<Ref<number>>(toRefsResult.a.value.b)
}
// toRef default value
{
const obj: { x?: number } = {}
const x = toRef(obj, 'x', 1)
expectType<Ref<number>>(x)
}
// #2687
interface AppData {
state: 'state1' | 'state2' | 'state3'