File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export interface Ref<T = any> {
20
20
_shallow ?: boolean
21
21
}
22
22
23
- export type ToRef < T > = T extends Ref ? T : Ref < UnwrapRef < T > >
23
+ export type ToRef < T > = [ T ] extends [ Ref ] ? T : Ref < UnwrapRef < T > >
24
24
export type ToRefs < T = any > = {
25
25
// #2687: somehow using ToRef<T[K]> here turns the resulting type into
26
26
// a union of multiple Ref<*> types instead of a single Ref<* | *> type.
Original file line number Diff line number Diff line change 9
9
proxyRefs ,
10
10
toRef ,
11
11
toRefs ,
12
- ToRefs
12
+ ToRefs ,
13
+ watch
13
14
} from './index'
14
15
15
16
function plainType ( arg : number | Ref < number > ) {
@@ -165,6 +166,14 @@ const obj = {
165
166
expectType < Ref < number > > ( toRef ( obj , 'a' ) )
166
167
expectType < Ref < number > > ( toRef ( obj , 'b' ) )
167
168
169
+ const objWithUnionProp : { a : string | number } = {
170
+ a : 1
171
+ }
172
+
173
+ watch ( toRef ( objWithUnionProp , 'a' ) , value => {
174
+ expectType < string | number > ( value )
175
+ } )
176
+
168
177
// toRefs
169
178
const objRefs = toRefs ( obj )
170
179
expectType < {
You can’t perform that action at this time.
0 commit comments