Browse Source

types: use normalized type for `RenderContext.scopedSlots` (#9624)

fix #9616
DSha 7 years ago
parent
commit
731e4d0ebc
3 changed files with 10 additions and 3 deletions
  1. 2 2
      types/options.d.ts
  2. 7 0
      types/test/vue-test.ts
  3. 1 1
      types/vue.d.ts

+ 2 - 2
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<Props=DefaultProps> {
   data: VNodeData;
   parent: Vue;
   listeners: { [key: string]: Function | Function[] };
-  scopedSlots: { [key: string]: ScopedSlot };
+  scopedSlots: { [key: string]: NormalizedScopedSlot };
   injections: any
 }
 

+ 7 - 0
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' }

+ 1 - 1
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 {