File tree 2 files changed +20
-7
lines changed
packages/runtime-core/src
2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -180,12 +180,15 @@ export const enum LifecycleHooks {
180
180
SERVER_PREFETCH = 'sp'
181
181
}
182
182
183
- export interface SetupContext < E = EmitsOptions > {
184
- attrs : Data
185
- slots : Slots
186
- emit : EmitFn < E >
187
- expose : ( exposed ?: Record < string , any > ) => void
188
- }
183
+ // use `E extends any` to force evaluating type to fix #2362
184
+ export type SetupContext < E = EmitsOptions > = E extends any
185
+ ? {
186
+ attrs : Data
187
+ slots : Slots
188
+ emit : EmitFn < E >
189
+ expose : ( exposed ?: Record < string , any > ) => void
190
+ }
191
+ : never
189
192
190
193
/**
191
194
* @internal
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ import {
11
11
FunctionalComponent ,
12
12
ComponentPublicInstance ,
13
13
toRefs ,
14
- IsAny
14
+ IsAny ,
15
+ SetupContext ,
16
+ expectAssignable
15
17
} from './index'
16
18
17
19
declare function extractComponentOptions < Props , RawBindings > (
@@ -476,3 +478,11 @@ describe('class', () => {
476
478
477
479
expectType < number > ( props . foo )
478
480
} )
481
+
482
+ describe ( 'SetupContext' , ( ) => {
483
+ describe ( 'can assign' , ( ) => {
484
+ const wider : SetupContext < { a : ( ) => true ; b : ( ) => true } > = { } as any
485
+
486
+ expectAssignable < SetupContext < { b : ( ) => true } > > ( wider )
487
+ } )
488
+ } )
You can’t perform that action at this time.
0 commit comments