Skip to content

Commit cae1aa8

Browse files
committed
chore: use stricter slots type in createSlots
1 parent 05c7b0d commit cae1aa8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/runtime-core/src/helpers/createSlots.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { Slot } from '../componentSlots'
21
import { isArray } from '@vue/shared'
2+
import { VNode } from '../vnode'
3+
4+
// #6651 res can be undefined in SSR in string push mode
5+
type SSRSlot = (...args: any[]) => VNode[] | undefined
36

47
interface CompiledSlotDescriptor {
58
name: string
6-
fn: Slot
9+
fn: SSRSlot
710
key?: string
811
}
912

@@ -12,13 +15,13 @@ interface CompiledSlotDescriptor {
1215
* @private
1316
*/
1417
export function createSlots(
15-
slots: Record<string, Slot>,
18+
slots: Record<string, SSRSlot>,
1619
dynamicSlots: (
1720
| CompiledSlotDescriptor
1821
| CompiledSlotDescriptor[]
1922
| undefined
2023
)[]
21-
): Record<string, Slot> {
24+
): Record<string, SSRSlot> {
2225
for (let i = 0; i < dynamicSlots.length; i++) {
2326
const slot = dynamicSlots[i]
2427
// array of dynamic slot generated by <template v-for="..." #[...]>
@@ -33,7 +36,6 @@ export function createSlots(
3336
const res = slot.fn(...args)
3437
// attach branch key so each conditional branch is considered a
3538
// different fragment
36-
// #6651 res can be undefined in SSR in string push mode
3739
if (res) (res as any).key = slot.key
3840
return res
3941
}

0 commit comments

Comments
 (0)