From 7d19b8d70e133fdb8f0877482bee23c8f36116e7 Mon Sep 17 00:00:00 2001 From: shasharoman Date: Tue, 5 Mar 2019 17:44:30 +0800 Subject: [PATCH 1/2] fix(#9616): modify the value type of `RenderContext.scopedSlots` --- types/options.d.ts | 4 ++-- types/vue.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/options.d.ts b/types/options.d.ts index 1bb5fbb619f..dcb38614ed3 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -1,5 +1,5 @@ import { Vue, CreateElement, CombinedVueInstance } from "./vue"; -import { VNode, VNodeData, VNodeDirective, ScopedSlot } from "./vnode"; +import { VNode, VNodeData, VNodeDirective, NormalizedScopedSlot } from "./vnode"; type Constructor = { new (...args: any[]): any; @@ -140,7 +140,7 @@ export interface RenderContext { data: VNodeData; parent: Vue; listeners: { [key: string]: Function | Function[] }; - scopedSlots: { [key: string]: ScopedSlot }; + scopedSlots: { [key: string]: NormalizedScopedSlot }; injections: any } diff --git a/types/vue.d.ts b/types/vue.d.ts index be2477b3f27..204f9cca94d 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -12,7 +12,7 @@ import { ThisTypedComponentOptionsWithRecordProps, WatchOptions, } from "./options"; -import { VNode, VNodeData, VNodeChildren, ScopedSlot, NormalizedScopedSlot } from "./vnode"; +import { VNode, VNodeData, VNodeChildren, NormalizedScopedSlot } from "./vnode"; import { PluginFunction, PluginObject } from "./plugin"; export interface CreateElement { From 05047bca7cc980ee6c43d00671644e9868a6dc7d Mon Sep 17 00:00:00 2001 From: shasharoman Date: Tue, 5 Mar 2019 17:53:26 +0800 Subject: [PATCH 2/2] test: test case for functional scoped slots --- types/test/vue-test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/test/vue-test.ts b/types/test/vue-test.ts index 54c4405264d..ca04e84714a 100644 --- a/types/test/vue-test.ts +++ b/types/test/vue-test.ts @@ -147,6 +147,13 @@ const FunctionalHelloWorldComponent = Vue.extend({ } }); +const FunctionalScopedSlotsComponent = Vue.extend({ + functional: true, + render(h, ctx) { + return ctx.scopedSlots.default && ctx.scopedSlots.default({}) || h('div', 'functional scoped slots'); + } +}); + const Parent = Vue.extend({ data() { return { greeting: 'Hello' }