From 551be9a45fdeed0d1f5c2a972855a4c77906aa7e Mon Sep 17 00:00:00 2001 From: Kael Date: Mon, 13 Aug 2018 02:40:48 +1000 Subject: [PATCH] fix(types): scoped slots can return a single VNode --- types/test/options-test.ts | 6 +++++- types/vnode.d.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 17a54fd360b..f48feec993c 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -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(); } diff --git a/types/vnode.d.ts b/types/vnode.d.ts index 5754c433dcd..8c4ef675e58 100644 --- a/types/vnode.d.ts +++ b/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 {}