Skip to content

Commit 49766bf

Browse files
authoredNov 23, 2020
fix(types): improve SetupContext types (#595)
1 parent 24bdcd2 commit 49766bf

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
 

‎src/component/componentOptions.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,27 @@ import { ComponentInstance, ComponentRenderProxy } from './componentProxy'
55

66
export interface SetupContext {
77
readonly attrs: Data
8-
readonly slots: { [key: string]: (...args: any[]) => VNode[] }
8+
readonly slots: Readonly<{ [key in string]?: (...args: any[]) => VNode[] }>
9+
10+
/**
11+
* @deprecated not avaliable in Vue 3
12+
*/
913
readonly parent: ComponentInstance | null
14+
15+
/**
16+
* @deprecated not avaliable in Vue 3
17+
*/
1018
readonly root: ComponentInstance
11-
readonly listeners: { [key: string]: Function }
19+
20+
/**
21+
* @deprecated not avaliable in Vue 3
22+
*/
23+
readonly listeners: { [key in string]?: Function }
24+
25+
/**
26+
* @deprecated not avaliable in Vue 3
27+
*/
28+
readonly refs: Data
1229

1330
emit(event: string, ...args: any[]): void
1431
}

‎src/mixin.ts

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export function mixin(Vue: VueConstructor) {
8888
def(props, '__ob__', createObserver())
8989

9090
// resolve scopedSlots and slots to functions
91+
// @ts-expect-error
9192
resolveScopedSlots(vm, ctx.slots)
9293

9394
let binding: ReturnType<SetupFunction<Data, Data>> | undefined | null
@@ -102,6 +103,7 @@ export function mixin(Vue: VueConstructor) {
102103
const bindingFunc = binding
103104
// keep currentInstance accessible for createElement
104105
vm.$options.render = () => {
106+
// @ts-expect-error
105107
resolveScopedSlots(vm, ctx.slots)
106108
return activateCurrentInstance(vm, () => bindingFunc())
107109
}

0 commit comments

Comments
 (0)
Please sign in to comment.