File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed
packages/runtime-core/src Expand file tree Collapse file tree 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 {
180180 SERVER_PREFETCH = 'sp'
181181}
182182
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
189192
190193/**
191194 * @internal
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ import {
1111 FunctionalComponent ,
1212 ComponentPublicInstance ,
1313 toRefs ,
14- IsAny
14+ IsAny ,
15+ SetupContext ,
16+ expectAssignable
1517} from './index'
1618
1719declare function extractComponentOptions < Props , RawBindings > (
@@ -476,3 +478,11 @@ describe('class', () => {
476478
477479 expectType < number > ( props . foo )
478480} )
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