From 908f70adc06038d1ea253d96f4024367f4a7545d Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 3 May 2024 16:29:23 -0700 Subject: [PATCH] fix(types): fix app.component() typing with inline defineComponent close #10843 --- packages/dts-test/defineComponent.test-d.tsx | 14 ++++++++++++++ packages/runtime-core/src/apiCreateApp.ts | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/dts-test/defineComponent.test-d.tsx b/packages/dts-test/defineComponent.test-d.tsx index aa0cfb0ebab..4af81be1dec 100644 --- a/packages/dts-test/defineComponent.test-d.tsx +++ b/packages/dts-test/defineComponent.test-d.tsx @@ -1959,3 +1959,17 @@ declare const ErrorMessage: { } }) ; + +// #10843 +createApp({}).component( + 'SomeComponent', + defineComponent({ + props: { + title: String, + }, + setup(props) { + expectType(props.title) + return {} + }, + }), +) diff --git a/packages/runtime-core/src/apiCreateApp.ts b/packages/runtime-core/src/apiCreateApp.ts index 286eb2bcc8e..12e63211a49 100644 --- a/packages/runtime-core/src/apiCreateApp.ts +++ b/packages/runtime-core/src/apiCreateApp.ts @@ -42,7 +42,10 @@ export interface App { mixin(mixin: ComponentOptions): this component(name: string): Component | undefined - component(name: string, component: Component | DefineComponent): this + component( + name: string, + component: T, + ): this directive(name: string): Directive | undefined directive(name: string, directive: Directive): this mount(