From 4baf852a34866c3ff5bfbb1f82e1f12e1c4b11d6 Mon Sep 17 00:00:00 2001 From: Carlos Rodrigues Date: Wed, 19 Aug 2020 15:00:48 +0100 Subject: [PATCH] types(runtime-core): make `FunctionalComponent` with emit string[] to be `Component` (#1879) fix #1847 --- packages/runtime-core/src/component.ts | 2 +- test-dts/functionalComponent.test-d.tsx | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index ee9ae1be5..cfc1a531b 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -110,7 +110,7 @@ export interface ClassComponent { __vccOpts: ComponentOptions } -export type Component = ComponentOptions | FunctionalComponent +export type Component = ComponentOptions | FunctionalComponent // A type used in public APIs where a component type is expected. // The constructor type is an artificial type returned by defineComponent(). diff --git a/test-dts/functionalComponent.test-d.tsx b/test-dts/functionalComponent.test-d.tsx index 6783fed61..c53c4287a 100644 --- a/test-dts/functionalComponent.test-d.tsx +++ b/test-dts/functionalComponent.test-d.tsx @@ -1,4 +1,9 @@ -import { FunctionalComponent, expectError, expectType } from './index' +import { + FunctionalComponent, + expectError, + expectType, + Component +} from './index' // simple function signature const Foo = (props: { foo: number }) => props.foo @@ -51,3 +56,10 @@ expectError() expectError() // @ts-expect-error expectError() + +const Baz: FunctionalComponent<{}, string[]> = (props, { emit }) => { + expectType<{}>(props) + expectType<(event: string) => void>(emit) +} + +expectType(Baz)