Skip to content

Commit

Permalink
fix(types): scoped slots can return a single VNode
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Oct 18, 2018
1 parent 0737d11 commit 551be9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion types/test/options-test.ts
Expand Up @@ -307,11 +307,15 @@ Vue.component('component-with-scoped-slot', {
Vue.component('narrow-array-of-vnode-type', {
render (h): VNode {
const slot = this.$scopedSlots.default({})
if (typeof slot !== 'string') {
if (Array.isArray(slot)) {
const first = slot[0]
if (!Array.isArray(first) && typeof first !== 'string') {
return first;
}
} else if (typeof slot === 'string') {
return h('div', slot.toUpperCase())
} else {
return slot
}
return h();
}
Expand Down
2 changes: 1 addition & 1 deletion types/vnode.d.ts
@@ -1,6 +1,6 @@
import { Vue } from "./vue";

export type ScopedSlot = (props: any) => VNodeChildrenArrayContents | string;
export type ScopedSlot = (props: any) => VNodeChildrenArrayContents | VNode | string;

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

0 comments on commit 551be9a

Please sign in to comment.