Skip to content

Commit

Permalink
types(runtime-core): default SetupContext generic argument to `Emit…
Browse files Browse the repository at this point in the history
…sOptions` (#1584)
  • Loading branch information
pikax authored Jul 15, 2020
1 parent 9188e9e commit d78a682
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const enum LifecycleHooks {
ERROR_CAPTURED = 'ec'
}

export interface SetupContext<E = ObjectEmitsOptions> {
export interface SetupContext<E = EmitsOptions> {
attrs: Data
slots: Slots
emit: EmitFn<E>
Expand Down
11 changes: 10 additions & 1 deletion test-dts/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
createApp,
expectError,
expectType,
ComponentPublicInstance
ComponentPublicInstance,
ComponentOptions,
SetupContext
} from './index'

describe('with object props', () => {
Expand Down Expand Up @@ -684,3 +686,10 @@ describe('emits', () => {
instance.$emit('test', 1)
instance.$emit('test')
})

describe('componentOptions setup should be `SetupContext`', () => {
expect<ComponentOptions['setup']>({} as (
props: Record<string, any>,
ctx: SetupContext
) => any)
})

0 comments on commit d78a682

Please sign in to comment.