types(runtime-core): make FunctionalComponent
with emit string[] to be Component
(#1879)
fix #1847
This commit is contained in:
parent
7f82428680
commit
4baf852a34
@ -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().
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user