Skip to content

Commit 551be9a

Browse files
committed
fix(types): scoped slots can return a single VNode
1 parent 0737d11 commit 551be9a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

types/test/options-test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,15 @@ Vue.component('component-with-scoped-slot', {
307307
Vue.component('narrow-array-of-vnode-type', {
308308
render (h): VNode {
309309
const slot = this.$scopedSlots.default({})
310-
if (typeof slot !== 'string') {
310+
if (Array.isArray(slot)) {
311311
const first = slot[0]
312312
if (!Array.isArray(first) && typeof first !== 'string') {
313313
return first;
314314
}
315+
} else if (typeof slot === 'string') {
316+
return h('div', slot.toUpperCase())
317+
} else {
318+
return slot
315319
}
316320
return h();
317321
}

types/vnode.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Vue } from "./vue";
22

3-
export type ScopedSlot = (props: any) => VNodeChildrenArrayContents | string;
3+
export type ScopedSlot = (props: any) => VNodeChildrenArrayContents | VNode | string;
44

55
export type VNodeChildren = VNodeChildrenArrayContents | [ScopedSlot] | string;
66
export interface VNodeChildrenArrayContents extends Array<VNode | string | VNodeChildrenArrayContents> {}

0 commit comments

Comments
 (0)