Skip to content

Commit 8e792d9

Browse files
authored
types(h): Support passing props to Component when using h (#3219)
1 parent cbc3e67 commit 8e792d9

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

packages/runtime-core/src/h.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ export function h<P>(
141141
): VNode
142142

143143
// component without props
144-
export function h(
145-
type: Component,
146-
props: null,
144+
export function h<P>(
145+
type: Component<P>,
146+
props?: (RawProps & P) | null,
147147
children?: RawChildren | RawSlots
148148
): VNode
149149

test-dts/h.test-d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,11 @@ describe('h inference w/ defineComponent', () => {
145145
// expectError(h(Foo, { bar: 1, foo: 1 }))
146146
// })
147147

148-
// #922
148+
// #922 and #3218
149149
describe('h support for generic component type', () => {
150150
function foo(bar: Component) {
151151
h(bar)
152152
h(bar, 'hello')
153-
// @ts-expect-error
154153
h(bar, { id: 'ok' }, 'hello')
155154
}
156155
foo({})

0 commit comments

Comments
 (0)