fix(types): ref value type unwrapping should happen at creation time
This commit is contained in:
@@ -13,6 +13,12 @@ function foo(arg: number | Ref<number>) {
|
||||
|
||||
// ref unwrapping
|
||||
expectType<number>(unref(arg))
|
||||
|
||||
// ref inner type should be unwrapped
|
||||
const nestedRef = ref({
|
||||
foo: ref(1)
|
||||
})
|
||||
expectType<Ref<{ foo: number }>>(nestedRef)
|
||||
}
|
||||
|
||||
foo(1)
|
||||
|
||||
@@ -52,3 +52,13 @@ watch(
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
// should provide correct ref.value inner type to callbacks
|
||||
const nestedRefSource = ref({
|
||||
foo: ref(1)
|
||||
})
|
||||
|
||||
watch(nestedRefSource, (v, ov) => {
|
||||
expectType<{ foo: number }>(v)
|
||||
expectType<{ foo: number }>(ov)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user