From 53b32434b247dd5f89debd5c56f64a2a780ef8db Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 23 Nov 2020 02:24:44 +0800 Subject: [PATCH 1/3] fix(types): improve SetupContext types --- src/component/componentOptions.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/component/componentOptions.ts b/src/component/componentOptions.ts index 5f0f1508..ff0543d6 100644 --- a/src/component/componentOptions.ts +++ b/src/component/componentOptions.ts @@ -5,11 +5,28 @@ import { ComponentInstance, ComponentRenderProxy } from './componentProxy' export interface SetupContext { readonly attrs: Data - readonly slots: { [key: string]: (...args: any[]) => VNode[] } + readonly slots: Readonly<{ [key: string]: (...args: any[]) => VNode[] }> + + /** + * @deprecated not avaliable in Vue 3 + */ readonly parent: ComponentInstance | null + + /** + * @deprecated not avaliable in Vue 3 + */ readonly root: ComponentInstance + + /** + * @deprecated not avaliable in Vue 3 + */ readonly listeners: { [key: string]: Function } + /** + * @deprecated not avaliable in Vue 3 + */ + readonly refs: { [key: string]: any } + emit(event: string, ...args: any[]): void } From 5b5810de57c1f3cd2eeadf2b638d5058d2c201ed Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 23 Nov 2020 04:52:32 +0800 Subject: [PATCH 2/3] chore: types --- src/component/componentOptions.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/component/componentOptions.ts b/src/component/componentOptions.ts index ff0543d6..c78decfc 100644 --- a/src/component/componentOptions.ts +++ b/src/component/componentOptions.ts @@ -5,7 +5,7 @@ import { ComponentInstance, ComponentRenderProxy } from './componentProxy' export interface SetupContext { readonly attrs: Data - readonly slots: Readonly<{ [key: string]: (...args: any[]) => VNode[] }> + readonly slots: Readonly<{ [key in string]?: (...args: any[]) => VNode[] }> /** * @deprecated not avaliable in Vue 3 @@ -20,12 +20,12 @@ export interface SetupContext { /** * @deprecated not avaliable in Vue 3 */ - readonly listeners: { [key: string]: Function } + readonly listeners: { [key in string]?: Function } /** * @deprecated not avaliable in Vue 3 */ - readonly refs: { [key: string]: any } + readonly refs: Data emit(event: string, ...args: any[]): void } From b7e178e23d75f59cf2af7881debe53911cb57979 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 23 Nov 2020 05:00:18 +0800 Subject: [PATCH 3/3] fix: ci --- src/mixin.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mixin.ts b/src/mixin.ts index 17fe2e80..0e67e4b6 100644 --- a/src/mixin.ts +++ b/src/mixin.ts @@ -88,6 +88,7 @@ export function mixin(Vue: VueConstructor) { def(props, '__ob__', createObserver()) // resolve scopedSlots and slots to functions + // @ts-expect-error resolveScopedSlots(vm, ctx.slots) let binding: ReturnType> | undefined | null @@ -102,6 +103,7 @@ export function mixin(Vue: VueConstructor) { const bindingFunc = binding // keep currentInstance accessible for createElement vm.$options.render = () => { + // @ts-expect-error resolveScopedSlots(vm, ctx.slots) return activateCurrentInstance(vm, () => bindingFunc()) }