File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1
- import { VNode , defineComponent } from '../../index'
1
+ import { VNode , defineComponent , ref } from '../../index'
2
2
import { expectType } from '../utils'
3
3
4
4
expectType < VNode > ( < div /> )
@@ -22,6 +22,11 @@ expectError(<div foo="bar" />)
22
22
expectType < JSX . Element > ( < div key = "foo" /> )
23
23
expectType < JSX . Element > ( < div ref = "bar" /> )
24
24
25
+ // allow Ref type type on arbitrary element
26
+ const fooRef = ref < HTMLElement > ( )
27
+ expectType < JSX . Element > ( < div ref = { fooRef } /> )
28
+ expectType < JSX . Element > ( < div ref = { ( el ) => { fooRef . value = el as HTMLElement } } /> )
29
+
25
30
expectType < JSX . Element > (
26
31
< input
27
32
onInput = { e => {
Original file line number Diff line number Diff line change 1
1
import { Vue } from './vue'
2
2
import { DirectiveFunction , DirectiveOptions } from './options'
3
+ import { Ref } from './v3-generated'
4
+ import { ComponentPublicInstance } from './v3-component-public-instance'
3
5
4
6
/**
5
7
* For extending allowed non-declared props on components in TSX
@@ -65,11 +67,19 @@ export interface VNodeComponentOptions {
65
67
tag ?: string
66
68
}
67
69
70
+ export type VNodeRef =
71
+ | string
72
+ | Ref
73
+ | ( (
74
+ ref : Element | ComponentPublicInstance | null ,
75
+ refs : Record < string , any >
76
+ ) => void )
77
+
68
78
export interface VNodeData {
69
79
key ?: string | number
70
80
slot ?: string
71
81
scopedSlots ?: { [ key : string ] : ScopedSlot | undefined }
72
- ref ?: string
82
+ ref ?: VNodeRef
73
83
refInFor ?: boolean
74
84
tag ?: string
75
85
staticClass ?: string
You can’t perform that action at this time.
0 commit comments