File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 9
9
Component ,
10
10
resolveComponent
11
11
} from 'vue'
12
- import { describe , expectAssignable } from './utils'
12
+ import { describe , expectAssignable , expectType } from './utils'
13
13
14
14
describe ( 'h inference w/ element' , ( ) => {
15
15
// key
@@ -32,6 +32,17 @@ describe('h inference w/ element', () => {
32
32
// slots
33
33
const slots = { default : ( ) => { } } // RawSlots
34
34
h ( 'div' , { } , slots )
35
+ // events
36
+ h ( 'div' , {
37
+ onClick : e => {
38
+ expectType < MouseEvent > ( e )
39
+ }
40
+ } )
41
+ h ( 'input' , {
42
+ onFocus ( e ) {
43
+ expectType < FocusEvent > ( e )
44
+ }
45
+ } )
35
46
} )
36
47
37
48
describe ( 'h inference w/ Fragment' , ( ) => {
Original file line number Diff line number Diff line change @@ -75,10 +75,27 @@ interface Constructor<P = any> {
75
75
new ( ...args : any [ ] ) : { $props : P }
76
76
}
77
77
78
+ type HTMLElementEventHandler = {
79
+ [ K in keyof HTMLElementEventMap as `on${Capitalize < K > } `] ?: (
80
+ ev : HTMLElementEventMap [ K ]
81
+ ) => any
82
+ }
83
+
78
84
// The following is a series of overloads for providing props validation of
79
85
// manually written render functions.
80
86
81
87
// element
88
+ export function h < K extends keyof HTMLElementTagNameMap > (
89
+ type : K ,
90
+ children ?: RawChildren
91
+ ) : VNode
92
+ export function h < K extends keyof HTMLElementTagNameMap > (
93
+ type : K ,
94
+ props ?: ( RawProps & HTMLElementEventHandler ) | null ,
95
+ children ?: RawChildren | RawSlots
96
+ ) : VNode
97
+
98
+ // custom element
82
99
export function h ( type : string , children ?: RawChildren ) : VNode
83
100
export function h (
84
101
type : string ,
You can’t perform that action at this time.
0 commit comments