]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
types(runtime-core): make `FunctionalComponent` with emit string[] to be `Component...
authorCarlos Rodrigues <david-181@hotmail.com>
Wed, 19 Aug 2020 14:00:48 +0000 (15:00 +0100)
committerGitHub <noreply@github.com>
Wed, 19 Aug 2020 14:00:48 +0000 (10:00 -0400)
fix #1847

packages/runtime-core/src/component.ts
test-dts/functionalComponent.test-d.tsx

index ee9ae1be5a43fe1a41fc5b10b32030d497e4c017..cfc1a531b86c898b87808c3f0aa09f9653b52143 100644 (file)
@@ -110,7 +110,7 @@ export interface ClassComponent {
   __vccOpts: ComponentOptions
 }
 
-export type Component = ComponentOptions | FunctionalComponent<any>
+export type Component = ComponentOptions | FunctionalComponent<any, any>
 
 // A type used in public APIs where a component type is expected.
 // The constructor type is an artificial type returned by defineComponent().
index 6783fed61c2a5f36ad2b357f8d22371800b5c24c..c53c4287a6e4046636882cb01be8bad88c669f7b 100644 (file)
@@ -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(<Foo />)
 expectError(<Bar foo="bar" />)
 //  @ts-expect-error
 expectError(<Foo baz="bar" />)
+
+const Baz: FunctionalComponent<{}, string[]> = (props, { emit }) => {
+  expectType<{}>(props)
+  expectType<(event: string) => void>(emit)
+}
+
+expectType<Component>(Baz)