File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 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> {
2020 _shallow ?: boolean
2121}
2222
23- export type ToRef < T > = T extends Ref ? T : Ref < UnwrapRef < T > >
23+ export type ToRef < T > = [ T ] extends [ Ref ] ? T : Ref < UnwrapRef < T > >
2424export type ToRefs < T = any > = {
2525 // #2687: somehow using ToRef<T[K]> here turns the resulting type into
2626 // a union of multiple Ref<*> types instead of a single Ref<* | *> type.
Original file line number Diff line number Diff line change 99 proxyRefs ,
1010 toRef ,
1111 toRefs ,
12- ToRefs
12+ ToRefs ,
13+ watch
1314} from './index'
1415
1516function plainType ( arg : number | Ref < number > ) {
@@ -165,6 +166,14 @@ const obj = {
165166expectType < Ref < number > > ( toRef ( obj , 'a' ) )
166167expectType < Ref < number > > ( toRef ( obj , 'b' ) )
167168
169+ const objWithUnionProp : { a : string | number } = {
170+ a : 1
171+ }
172+
173+ watch ( toRef ( objWithUnionProp , 'a' ) , value => {
174+ expectType < string | number > ( value )
175+ } )
176+
168177// toRefs
169178const objRefs = toRefs ( obj )
170179expectType < {
You can’t perform that action at this time.
0 commit comments