File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 11import {
22 h ,
33 defineComponent ,
4+ DefineComponent ,
45 ref ,
56 Fragment ,
67 Teleport ,
@@ -231,3 +232,18 @@ describe('resolveComponent should work', () => {
231232 message : '1'
232233 } )
233234} )
235+
236+ // #5431
237+ describe ( 'h should work with multiple types' , ( ) => {
238+ const serializers = {
239+ Paragraph : 'p' ,
240+ Component : { } as Component ,
241+ DefineComponent : { } as DefineComponent
242+ }
243+
244+ const sampleComponent = serializers [ '' as keyof typeof serializers ]
245+
246+ h ( sampleComponent )
247+ h ( sampleComponent , { } )
248+ h ( sampleComponent , { } , [ ] )
249+ } )
Original file line number Diff line number Diff line change @@ -174,6 +174,14 @@ export function h<P>(
174174 children ?: RawChildren | RawSlots
175175) : VNode
176176
177+ // catch all types
178+ export function h ( type : string | Component , children ?: RawChildren ) : VNode
179+ export function h < P > (
180+ type : string | Component < P > ,
181+ props ?: ( RawProps & P ) | ( { } extends P ? null : never ) ,
182+ children ?: RawChildren | RawSlots
183+ ) : VNode
184+
177185// Actual implementation
178186export function h ( type : any , propsOrChildren ?: any , children ?: any ) : VNode {
179187 const l = arguments . length
You can’t perform that action at this time.
0 commit comments