types(runtime-core): default SetupContext generic argument to EmitsOptions (#1584)

This commit is contained in:
Carlos Rodrigues 2020-07-15 14:19:20 +01:00 committed by GitHub
parent 9188e9ea74
commit d78a6821f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -132,7 +132,7 @@ export const enum LifecycleHooks {
ERROR_CAPTURED = 'ec' ERROR_CAPTURED = 'ec'
} }
export interface SetupContext<E = ObjectEmitsOptions> { export interface SetupContext<E = EmitsOptions> {
attrs: Data attrs: Data
slots: Slots slots: Slots
emit: EmitFn<E> emit: EmitFn<E>

View File

@ -7,7 +7,9 @@ import {
createApp, createApp,
expectError, expectError,
expectType, expectType,
ComponentPublicInstance ComponentPublicInstance,
ComponentOptions,
SetupContext
} from './index' } from './index'
describe('with object props', () => { describe('with object props', () => {
@ -684,3 +686,10 @@ describe('emits', () => {
instance.$emit('test', 1) instance.$emit('test', 1)
instance.$emit('test') instance.$emit('test')
}) })
describe('componentOptions setup should be `SetupContext`', () => {
expect<ComponentOptions['setup']>({} as (
props: Record<string, any>,
ctx: SetupContext
) => any)
})