Skip to content

Commit 908f70a

Browse files
committed
fix(types): fix app.component() typing with inline defineComponent
close #10843
1 parent eae0ccb commit 908f70a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/dts-test/defineComponent.test-d.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -1959,3 +1959,17 @@ declare const ErrorMessage: {
19591959
}
19601960
})
19611961
;<ErrorMessage name="password" class="error" />
1962+
1963+
// #10843
1964+
createApp({}).component(
1965+
'SomeComponent',
1966+
defineComponent({
1967+
props: {
1968+
title: String,
1969+
},
1970+
setup(props) {
1971+
expectType<string | undefined>(props.title)
1972+
return {}
1973+
},
1974+
}),
1975+
)

packages/runtime-core/src/apiCreateApp.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ export interface App<HostElement = any> {
4242

4343
mixin(mixin: ComponentOptions): this
4444
component(name: string): Component | undefined
45-
component(name: string, component: Component | DefineComponent): this
45+
component<T extends Component | DefineComponent>(
46+
name: string,
47+
component: T,
48+
): this
4649
directive<T = any, V = any>(name: string): Directive<T, V> | undefined
4750
directive<T = any, V = any>(name: string, directive: Directive<T, V>): this
4851
mount(

0 commit comments

Comments
 (0)