Pārlūkot izejas kodu

types(h): Support passing `props` to `Component` when using `h` (#3219)

Carlos Rodrigues 3 gadi atpakaļ
vecāks
revīzija
8e792d93a8
2 mainītis faili ar 4 papildinājumiem un 5 dzēšanām
  1. 3 3
      packages/runtime-core/src/h.ts
  2. 1 2
      test-dts/h.test-d.ts

+ 3 - 3
packages/runtime-core/src/h.ts

@@ -141,9 +141,9 @@ export function h<P>(
 ): VNode
 
 // component without props
-export function h(
-  type: Component,
-  props: null,
+export function h<P>(
+  type: Component<P>,
+  props?: (RawProps & P) | null,
   children?: RawChildren | RawSlots
 ): VNode
 

+ 1 - 2
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({})