]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(types): add RawSlots in h signature (#1293)
authorCédric Exbrayat <cexbrayat@users.noreply.github.com>
Fri, 12 Jun 2020 14:38:56 +0000 (16:38 +0200)
committerGitHub <noreply@github.com>
Fri, 12 Jun 2020 14:38:56 +0000 (10:38 -0400)
packages/runtime-core/__tests__/h.spec.ts
packages/runtime-core/src/h.ts
test-dts/h.test-d.ts

index b55c9f4820b0e9beb024124ad6b8f5aa0d3085b4..1e1c6fb8d82e4ef0ff94fedd6cd237b5ef2f3b86 100644 (file)
@@ -1,5 +1,6 @@
 import { h } from '../src/h'
 import { createVNode } from '../src/vnode'
+import { RawSlots } from '../src/componentSlots'
 
 // Since h is a thin layer on top of createVNode, we are only testing its
 // own logic here. Details of vnode creation is tested in vnode.spec.ts.
@@ -31,8 +32,14 @@ describe('renderer: h', () => {
   test('type + props + children', () => {
     // array
     expect(h('div', {}, ['foo'])).toMatchObject(createVNode('div', {}, ['foo']))
-    // default slot
+    // slots
+    const slots = {} as RawSlots
+    expect(h('div', {}, slots)).toMatchObject(createVNode('div', {}, slots))
     const Component = { template: '<br />' }
+    expect(h(Component, {}, slots)).toMatchObject(
+      createVNode(Component, {}, slots)
+    )
+    // default slot
     const slot = () => {}
     expect(h(Component, {}, slot)).toMatchObject(
       createVNode(Component, {}, slot)
index 4e644c3e05510b8d28f193aacae725beb3c8fecb..2b5d8c54e15ac87b63153db76ff4597361578ab8 100644 (file)
@@ -80,7 +80,7 @@ export function h(type: string, children?: RawChildren): VNode
 export function h(
   type: string,
   props?: RawProps | null,
-  children?: RawChildren
+  children?: RawChildren | RawSlots
 ): VNode
 
 // fragment
index 7f7ec3c35edfba072f4ee949bc9e61a65a3654d4..0b7687536d665e167fb4fab935750eeadf794ce3 100644 (file)
@@ -29,6 +29,9 @@ describe('h inference w/ element', () => {
   expectError(h('div', { ref: {} }))
   //  @ts-expect-error
   expectError(h('div', { ref: 123 }))
+  // slots
+  const slots = { default: () => {} } // RawSlots
+  h('div', {}, slots)
 })
 
 describe('h inference w/ Fragment', () => {