From: Carlos Rodrigues Date: Wed, 19 Aug 2020 14:00:48 +0000 (+0100) Subject: types(runtime-core): make `FunctionalComponent` with emit string[] to be `Component... X-Git-Tag: v3.0.0-rc.6~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4baf852a34866c3ff5bfbb1f82e1f12e1c4b11d6;p=thirdparty%2Fvuejs%2Fcore.git types(runtime-core): make `FunctionalComponent` with emit string[] to be `Component` (#1879) fix #1847 --- diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index ee9ae1be5a..cfc1a531b8 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 6783fed61c..c53c4287a6 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)