Skip to content

Commit 4baf852

Browse files
authored
types(runtime-core): make FunctionalComponent with emit string[] to be Component (#1879)
fix #1847
1 parent 7f82428 commit 4baf852

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/runtime-core/src/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export interface ClassComponent {
110110
__vccOpts: ComponentOptions
111111
}
112112

113-
export type Component = ComponentOptions | FunctionalComponent<any>
113+
export type Component = ComponentOptions | FunctionalComponent<any, any>
114114

115115
// A type used in public APIs where a component type is expected.
116116
// The constructor type is an artificial type returned by defineComponent().

test-dts/functionalComponent.test-d.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { FunctionalComponent, expectError, expectType } from './index'
1+
import {
2+
FunctionalComponent,
3+
expectError,
4+
expectType,
5+
Component
6+
} from './index'
27

38
// simple function signature
49
const Foo = (props: { foo: number }) => props.foo
@@ -51,3 +56,10 @@ expectError(<Foo />)
5156
expectError(<Bar foo="bar" />)
5257
// @ts-expect-error
5358
expectError(<Foo baz="bar" />)
59+
60+
const Baz: FunctionalComponent<{}, string[]> = (props, { emit }) => {
61+
expectType<{}>(props)
62+
expectType<(event: string) => void>(emit)
63+
}
64+
65+
expectType<Component>(Baz)

0 commit comments

Comments
 (0)