parent
69b74a806f
commit
127ed1b969
@ -85,7 +85,7 @@ export function triggerRef(ref: Ref) {
|
||||
trigger(toRaw(ref), TriggerOpTypes.SET, 'value', __DEV__ ? ref.value : void 0)
|
||||
}
|
||||
|
||||
export function unref<T>(ref: T): T extends Ref<infer V> ? V : T {
|
||||
export function unref<T>(ref: T | Ref<T>): T {
|
||||
return isRef(ref) ? (ref.value as any) : ref
|
||||
}
|
||||
|
||||
|
@ -203,3 +203,10 @@ switch (data.state.value) {
|
||||
data.state.value = 'state1'
|
||||
break
|
||||
}
|
||||
|
||||
// #3954
|
||||
function testUnrefGenerics<T>(p: T | Ref<T>) {
|
||||
expectType<T>(unref(p))
|
||||
}
|
||||
|
||||
testUnrefGenerics(1)
|
||||
|
Loading…
Reference in New Issue
Block a user