Skip to content

Commit

Permalink
types(defineComponent): Support emit when using functionalComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
pikax committed Oct 27, 2020
1 parent 9c23ddf commit 83e9abd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/runtime-core/src/apiDefineComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ export type DefineComponent<

// overload 1: direct setup function
// (uses user defined props interface)
export function defineComponent<Props, RawBindings = object>(
export function defineComponent<
Props,
RawBindings = object,
E extends EmitsOptions = {}
>(
setup: (
props: Readonly<Props>,
ctx: SetupContext
ctx: SetupContext<E>
) => RawBindings | RenderFunction
): DefineComponent<Props, RawBindings>

Expand Down
9 changes: 9 additions & 0 deletions test-dts/component.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,15 @@ describe('functional', () => {

expectType<number>(props.foo)
})

describe('emit', () => {
const MyComponent: FunctionalComponent<
{ foo: number },
{ ev: (a: string) => void }
> = (_, _2) => {}

defineComponent(MyComponent)
})
})

declare type VueClass<Props = {}> = {
Expand Down

0 comments on commit 83e9abd

Please sign in to comment.