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>(
128
128
// RelativePath extends object -> true
129
129
type BaseTypes = string | number | boolean | Node | Window
130
130
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
-
136
131
export type UnwrapRef < T > = T extends ComputedRef < infer V >
137
132
? UnwrapRefSimple < V >
138
133
: T extends Ref < infer V > ? UnwrapRefSimple < V > : UnwrapRefSimple < T >
139
134
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
146
136
? 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
156
138
157
139
// Extract all known symbols from an object
158
140
// 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>) {
21
21
expectType < Ref < { foo : number } > > ( nestedRef )
22
22
expectType < { foo : number } > ( nestedRef . value )
23
23
24
+ // tuple
25
+ expectType < [ number , string ] > ( unref ( ref ( [ 1 , '1' ] ) ) )
26
+
24
27
interface IteratorFoo {
25
28
[ Symbol . iterator ] : any
26
29
}
27
- expectType < Ref < UnwrapRef < IteratorFoo > > | Ref < null > > (
28
- ref < IteratorFoo | null > ( null )
29
- )
30
30
31
- expectType < Ref < HTMLElement > | Ref < null > > ( ref < HTMLElement | null > ( null ) )
31
+ // with symbol
32
+ expectType < IteratorFoo | null > ( unref ( ref < IteratorFoo | null > ( null ) ) )
32
33
}
33
34
34
35
plainType ( 1 )
You can’t perform that action at this time.
0 commit comments