types(reactivity): add support for tuples in ref unwrapping (#436)

This commit is contained in:
Carlos Rodrigues
2019-11-08 17:52:24 +00:00
committed by Evan You
parent d7d87622ce
commit 68ad302714
2 changed files with 25 additions and 2 deletions

View File

@@ -72,11 +72,13 @@ function toProxyRef<T extends object, K extends keyof T>(
}
}
type UnwrapArray<T> = { [P in keyof T]: UnwrapRef<T[P]> }
// Recursively unwraps nested value bindings.
export type UnwrapRef<T> = {
cRef: T extends ComputedRef<infer V> ? UnwrapRef<V> : T
ref: T extends Ref<infer V> ? UnwrapRef<V> : T
array: T extends Array<infer V> ? Array<UnwrapRef<V>> : T
array: T extends Array<infer V> ? Array<UnwrapRef<V>> & UnwrapArray<T> : T
object: { [K in keyof T]: UnwrapRef<T[K]> }
}[T extends ComputedRef<any>
? 'cRef'