From 7514ff6e9a8a22f21b8e312156019cf84bc95331 Mon Sep 17 00:00:00 2001 From: thenickname Date: Sun, 14 Oct 2018 20:34:36 +0200 Subject: [PATCH 1/3] fix(types): Declare $scopedSlots as potentially undefined to enable stricter TS checks --- types/vue.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vue.d.ts b/types/vue.d.ts index 179fb5fe38e..f434b3449fa 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -28,7 +28,7 @@ export interface Vue { readonly $children: Vue[]; readonly $refs: { [key: string]: Vue | Element | Vue[] | Element[] }; readonly $slots: { [key: string]: VNode[] }; - readonly $scopedSlots: { [key: string]: ScopedSlot }; + readonly $scopedSlots: { [key: string]: ScopedSlot | undefined }; readonly $isServer: boolean; readonly $data: Record; readonly $props: Record; From 4de014319ef91bc6c43cabb245a0d33cd98ef629 Mon Sep 17 00:00:00 2001 From: thenickname Date: Sun, 14 Oct 2018 20:39:58 +0200 Subject: [PATCH 2/3] fix(types): Fix tests --- types/test/options-test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 17a54fd360b..dc334b0f31e 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -296,8 +296,8 @@ Vue.component('component-with-scoped-slot', { child: { render (this: Vue, h: CreateElement) { return h('div', [ - this.$scopedSlots['default']({ msg: 'hi' }), - this.$scopedSlots['item']({ msg: 'hello' }) + this.$scopedSlots['default']!({ msg: 'hi' }), + this.$scopedSlots['item']!({ msg: 'hello' }) ]) } } @@ -306,7 +306,7 @@ Vue.component('component-with-scoped-slot', { Vue.component('narrow-array-of-vnode-type', { render (h): VNode { - const slot = this.$scopedSlots.default({}) + const slot = this.$scopedSlots.default!({}) if (typeof slot !== 'string') { const first = slot[0] if (!Array.isArray(first) && typeof first !== 'string') { From fbaa3924d8f2560bc586e73bbce8356c5d76291a Mon Sep 17 00:00:00 2001 From: thenickname Date: Mon, 22 Oct 2018 22:59:29 +0200 Subject: [PATCH 3/3] fix(types): declare $slots option as potentially undefined declare $slots option as potentially undefined to enable stricter TS checks --- types/vue.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vue.d.ts b/types/vue.d.ts index f434b3449fa..af51c106e33 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -27,7 +27,7 @@ export interface Vue { readonly $root: Vue; readonly $children: Vue[]; readonly $refs: { [key: string]: Vue | Element | Vue[] | Element[] }; - readonly $slots: { [key: string]: VNode[] }; + readonly $slots: { [key: string]: VNode[] | undefined }; readonly $scopedSlots: { [key: string]: ScopedSlot | undefined }; readonly $isServer: boolean; readonly $data: Record;