@@ -103,16 +103,27 @@ function toProxyRef<T extends object, K extends keyof T>(
103103// RelativePath extends object -> true
104104type BaseTypes = string | number | boolean
105105
106- // Recursively unwraps nested value bindings.
107- export type UnwrapRef < T > = {
108- cRef : T extends ComputedRef < infer V > ? UnwrapRef < V > : T
109- ref : T extends Ref < infer V > ? UnwrapRef < V > : T
110- array : T
111- object : { [ K in keyof T ] : UnwrapRef < T [ K ] > }
112- } [ T extends ComputedRef < any >
113- ? 'cRef'
114- : T extends Array < any >
115- ? 'array'
116- : T extends Ref | Function | CollectionTypes | BaseTypes
117- ? 'ref' // bail out on types that shouldn't be unwrapped
118- : T extends object ? 'object' : 'ref' ]
106+ // Super simple tuple checker
107+ type Tupple < T extends Array < any > > = T [ 0 ] extends T [ 1 ]
108+ ? T [ 1 ] extends T [ 2 ] ? never : true
109+ : true
110+
111+ export type UnwrapRef < T > = T extends ComputedRef < infer V >
112+ ? UnwrapRefSimple < V >
113+ : T extends Ref < infer V > ? UnwrapRefSimple < V > : UnwrapRefSimple < T >
114+
115+ type UnwrapRefSimple < T > = T extends Function | CollectionTypes | BaseTypes | Ref
116+ ? T
117+ : T extends Array < infer V >
118+ ? Tupple < T > extends never ? Array < V > : UnwrapTupple < T >
119+ : T extends object ? UnwrappedObject < T > : T
120+
121+ export type UnwrapTupple < T > = { [ P in keyof T ] : T [ P ] } & {
122+ length : number
123+ [ Symbol . iterator ] : any
124+ [ Symbol . unscopables ] : any
125+ }
126+
127+ // interface UnwrappedArray<T> extends Array<T> {}
128+
129+ type UnwrappedObject < T > = { [ P in keyof T ] : UnwrapRef < T [ P ] > }
0 commit comments