]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: use stricter slots type in createSlots
authorEvan You <yyx990803@gmail.com>
Wed, 28 Sep 2022 02:38:19 +0000 (10:38 +0800)
committerEvan You <yyx990803@gmail.com>
Wed, 28 Sep 2022 02:38:27 +0000 (10:38 +0800)
packages/runtime-core/src/helpers/createSlots.ts

index b44d1f1090ba5daab34730bf2e59f890bdb30d2e..f370f5ca8038d45e38e2844a0d11ab5931525882 100644 (file)
@@ -1,9 +1,12 @@
-import { Slot } from '../componentSlots'
 import { isArray } from '@vue/shared'
+import { VNode } from '../vnode'
+
+// #6651 res can be undefined in SSR in string push mode
+type SSRSlot = (...args: any[]) => VNode[] | undefined
 
 interface CompiledSlotDescriptor {
   name: string
-  fn: Slot
+  fn: SSRSlot
   key?: string
 }
 
@@ -12,13 +15,13 @@ interface CompiledSlotDescriptor {
  * @private
  */
 export function createSlots(
-  slots: Record<string, Slot>,
+  slots: Record<string, SSRSlot>,
   dynamicSlots: (
     | CompiledSlotDescriptor
     | CompiledSlotDescriptor[]
     | undefined
   )[]
-): Record<string, Slot> {
+): Record<string, SSRSlot> {
   for (let i = 0; i < dynamicSlots.length; i++) {
     const slot = dynamicSlots[i]
     // array of dynamic slot generated by <template v-for="..." #[...]>
@@ -33,7 +36,6 @@ export function createSlots(
             const res = slot.fn(...args)
             // attach branch key so each conditional branch is considered a
             // different fragment
-            // #6651 res can be undefined in SSR in string push mode
             if (res) (res as any).key = slot.key
             return res
           }