File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ function toProxyRef<T extends object, K extends keyof T>(
101
101
// corner case when use narrows type
102
102
// Ex. type RelativePath = string & { __brand: unknown }
103
103
// RelativePath extends object -> true
104
- type BaseTypes = string | number | boolean
104
+ type BaseTypes = string | number | boolean | Node | Window
105
105
106
106
// Recursively unwraps nested value bindings.
107
107
export type UnwrapRef < T > = {
Original file line number Diff line number Diff line change 1
1
import { expectType } from 'tsd'
2
2
import { Ref , ref , isRef , unref } from './index'
3
3
4
- function foo ( arg : number | Ref < number > ) {
4
+ function plainType ( arg : number | Ref < number > ) {
5
5
// ref coercing
6
6
const coerced = ref ( arg )
7
7
expectType < Ref < number > > ( coerced )
@@ -22,4 +22,26 @@ function foo(arg: number | Ref<number>) {
22
22
expectType < { foo : number } > ( nestedRef . value )
23
23
}
24
24
25
- foo ( 1 )
25
+ plainType ( 1 )
26
+
27
+ function bailType ( arg : HTMLElement | Ref < HTMLElement > ) {
28
+ // ref coercing
29
+ const coerced = ref ( arg )
30
+ expectType < Ref < HTMLElement > > ( coerced )
31
+
32
+ // isRef as type guard
33
+ if ( isRef ( arg ) ) {
34
+ expectType < Ref < HTMLElement > > ( arg )
35
+ }
36
+
37
+ // ref unwrapping
38
+ expectType < HTMLElement > ( unref ( arg ) )
39
+
40
+ // ref inner type should be unwrapped
41
+ const nestedRef = ref ( { foo : ref ( document . createElement ( 'DIV' ) ) } )
42
+
43
+ expectType < Ref < { foo : HTMLElement } > > ( nestedRef )
44
+ expectType < { foo : HTMLElement } > ( nestedRef . value )
45
+ }
46
+ const el = document . createElement ( 'DIV' )
47
+ bailType ( el )
You can’t perform that action at this time.
0 commit comments