From d78a6821f50a0d2603ea40eebaf3cbf52bbe0af4 Mon Sep 17 00:00:00 2001 From: Carlos Rodrigues Date: Wed, 15 Jul 2020 14:19:20 +0100 Subject: [PATCH] types(runtime-core): default `SetupContext` generic argument to `EmitsOptions` (#1584) --- packages/runtime-core/src/component.ts | 2 +- test-dts/defineComponent.test-d.tsx | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 21d4fe67bb4..404bb15bd4c 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -132,7 +132,7 @@ export const enum LifecycleHooks { ERROR_CAPTURED = 'ec' } -export interface SetupContext { +export interface SetupContext { attrs: Data slots: Slots emit: EmitFn diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index 009ddbf5414..9063ef5dab3 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -7,7 +7,9 @@ import { createApp, expectError, expectType, - ComponentPublicInstance + ComponentPublicInstance, + ComponentOptions, + SetupContext } from './index' describe('with object props', () => { @@ -684,3 +686,10 @@ describe('emits', () => { instance.$emit('test', 1) instance.$emit('test') }) + +describe('componentOptions setup should be `SetupContext`', () => { + expect({} as ( + props: Record, + ctx: SetupContext + ) => any) +})