types: improve type error logging and nest ref types
This commit is contained in:
parent
fa5390fb6f
commit
14f1814292
@ -84,18 +84,20 @@ function toProxyRef<T extends object, K extends keyof T>(
|
|||||||
|
|
||||||
type UnwrapArray<T> = { [P in keyof T]: UnwrapRef<T[P]> }
|
type UnwrapArray<T> = { [P in keyof T]: UnwrapRef<T[P]> }
|
||||||
|
|
||||||
// Recursively unwraps nested value bindings.
|
type UnwrapProp<T> = T extends ComputedRef<infer V>
|
||||||
export type UnwrapRef<T> = {
|
? UnwrapRef<V>
|
||||||
cRef: T extends ComputedRef<infer V> ? UnwrapRef<V> : T
|
: T extends Ref<infer V>
|
||||||
ref: T extends Ref<infer V> ? UnwrapRef<V> : T
|
? UnwrapRef<V>
|
||||||
array: T extends Array<infer V> ? Array<UnwrapRef<V>> & UnwrapArray<T> : T
|
: T extends Function | CollectionTypes
|
||||||
object: { [K in keyof T]: UnwrapRef<T[K]> }
|
? T
|
||||||
}[T extends ComputedRef<any>
|
: T extends object
|
||||||
? 'cRef'
|
? UnwrapObject<T>
|
||||||
: T extends Ref
|
: T extends Array<infer V> ? Array<UnwrapRef<V>> & UnwrapArray<T> : T
|
||||||
? 'ref'
|
|
||||||
: T extends Array<any>
|
type UnwrapObject<T> = { [K in keyof T]: UnwrapProp<T[K]> }
|
||||||
? 'array'
|
|
||||||
: T extends Function | CollectionTypes
|
export type UnwrapRef<T> = T extends object
|
||||||
? 'ref' // bail out on types that shouldn't be unwrapped
|
? UnwrapObject<T>
|
||||||
: T extends object ? 'object' : 'ref']
|
: T extends Function | CollectionTypes
|
||||||
|
? T
|
||||||
|
: T extends Array<infer V> ? Array<UnwrapRef<V>> & UnwrapArray<T> : T
|
||||||
|
Loading…
x
Reference in New Issue
Block a user