1
1
import { proxyRefs } from '@vue/reactivity'
2
- import { isArray , isFunction , isObject } from '@vue/shared'
2
+ import { type Data , isArray , isFunction , isObject } from '@vue/shared'
3
3
import { type ComponentInternalInstance , setCurrentInstance } from './component'
4
4
import { getAttrsProxy } from './componentAttrs'
5
- // import { SetupContext } from 'vue'
6
5
import { type Block , fragmentKey } from './apiRender'
6
+ import type { EmitFn , EmitsOptions } from './componentEmits'
7
+
8
+ export type SetupContext < E = EmitsOptions > = E extends any
9
+ ? {
10
+ attrs : Data
11
+ emit : EmitFn < E >
12
+ expose : ( exposed ?: Record < string , any > ) => void
13
+ }
14
+ : never
7
15
8
16
export function setupComponent ( instance : ComponentInternalInstance ) : void {
9
17
const reset = setCurrentInstance ( instance )
@@ -42,7 +50,9 @@ export function setupComponent(instance: ComponentInternalInstance): void {
42
50
reset ( )
43
51
}
44
52
45
- export function createSetupContext ( instance : ComponentInternalInstance ) : any {
53
+ export function createSetupContext (
54
+ instance : ComponentInternalInstance ,
55
+ ) : SetupContext {
46
56
if ( __DEV__ ) {
47
57
// We use getters in dev in case libs like test-utils overwrite instance
48
58
// properties (overwrites should not be done in prod)
@@ -57,6 +67,7 @@ export function createSetupContext(instance: ComponentInternalInstance): any {
57
67
} )
58
68
} else {
59
69
return {
70
+ expose : ( ) => { } ,
60
71
get attrs ( ) {
61
72
return getAttrsProxy ( instance )
62
73
} ,
0 commit comments