From 8e792d93a8062e29d9da279eee2202f38897f42f Mon Sep 17 00:00:00 2001 From: Carlos Rodrigues Date: Wed, 26 Oct 2022 08:07:44 +0100 Subject: [PATCH] types(h): Support passing `props` to `Component` when using `h` (#3219) --- packages/runtime-core/src/h.ts | 6 +++--- test-dts/h.test-d.ts | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/runtime-core/src/h.ts b/packages/runtime-core/src/h.ts index 44f9134082..520f568e7a 100644 --- a/packages/runtime-core/src/h.ts +++ b/packages/runtime-core/src/h.ts @@ -141,9 +141,9 @@ export function h

( ): VNode // component without props -export function h( - type: Component, - props: null, +export function h

( + type: Component

, + props?: (RawProps & P) | null, children?: RawChildren | RawSlots ): VNode diff --git a/test-dts/h.test-d.ts b/test-dts/h.test-d.ts index 5318f71fe9..6116fff74a 100644 --- a/test-dts/h.test-d.ts +++ b/test-dts/h.test-d.ts @@ -145,12 +145,11 @@ describe('h inference w/ defineComponent', () => { // expectError(h(Foo, { bar: 1, foo: 1 })) // }) -// #922 +// #922 and #3218 describe('h support for generic component type', () => { function foo(bar: Component) { h(bar) h(bar, 'hello') - // @ts-expect-error h(bar, { id: 'ok' }, 'hello') } foo({}) -- 2.47.3