File tree Expand file tree Collapse file tree 2 files changed +7
-24
lines changed
Expand file tree Collapse file tree 2 files changed +7
-24
lines changed Original file line number Diff line number Diff line change @@ -128,31 +128,13 @@ export function toRef<T extends object, K extends keyof T>(
128128// RelativePath extends object -> true
129129type BaseTypes = string | number | boolean | Node | Window
130130
131- // Super simple tuple checker
132- type IsTuple < T extends Array < any > > = T [ 0 ] extends T [ 1 ]
133- ? T [ 1 ] extends T [ 2 ] ? never : true
134- : true
135-
136131export type UnwrapRef < T > = T extends ComputedRef < infer V >
137132 ? UnwrapRefSimple < V >
138133 : T extends Ref < infer V > ? UnwrapRefSimple < V > : UnwrapRefSimple < T >
139134
140- type UnwrapRefSimple < T > = T extends
141- | Function
142- | CollectionTypes
143- | BaseTypes
144- | Ref
145- | Element
135+ type UnwrapRefSimple < T > = T extends Function | CollectionTypes | BaseTypes | Ref
146136 ? T
147- : T extends Array < infer V >
148- ? IsTuple < T > extends true ? UnwrapTuple < T > : Array < V >
149- : T extends object ? UnwrappedObject < T > : T
150-
151- export type UnwrapTuple < T > = { [ P in keyof T ] : T [ P ] } & {
152- length : number
153- [ Symbol . iterator ] : any
154- [ Symbol . unscopables ] : any
155- }
137+ : T extends Array < any > ? T : T extends object ? UnwrappedObject < T > : T
156138
157139// Extract all known symbols from an object
158140// when unwrapping Object the symbols are not `in keyof`, this should cover all the
Original file line number Diff line number Diff line change @@ -21,14 +21,15 @@ function plainType(arg: number | Ref<number>) {
2121 expectType < Ref < { foo : number } > > ( nestedRef )
2222 expectType < { foo : number } > ( nestedRef . value )
2323
24+ // tuple
25+ expectType < [ number , string ] > ( unref ( ref ( [ 1 , '1' ] ) ) )
26+
2427 interface IteratorFoo {
2528 [ Symbol . iterator ] : any
2629 }
27- expectType < Ref < UnwrapRef < IteratorFoo > > | Ref < null > > (
28- ref < IteratorFoo | null > ( null )
29- )
3030
31- expectType < Ref < HTMLElement > | Ref < null > > ( ref < HTMLElement | null > ( null ) )
31+ // with symbol
32+ expectType < IteratorFoo | null > ( unref ( ref < IteratorFoo | null > ( null ) ) )
3233}
3334
3435plainType ( 1 )
You can’t perform that action at this time.
0 commit comments