fix(types): fix type inference when using components option

This commit is contained in:
Evan You 2022-07-08 15:15:22 +08:00
parent dc8a68e8c6
commit 1d5a411c1e
2 changed files with 26 additions and 3 deletions

6
types/options.d.ts vendored
View File

@ -20,7 +20,7 @@ export type Component<
| typeof Vue
| FunctionalComponentOptions<Props>
| ComponentOptions<never, Data, Methods, Computed, Props, SetupBindings>
| DefineComponent<any, any, any, any, any>
| DefineComponent<any, any, any, any, any, any, any, any, any, any, any>
type EsModule<T> = T | { default: T }
@ -201,9 +201,9 @@ export interface ComponentOptions<
directives?: { [key: string]: DirectiveFunction | DirectiveOptions }
components?: {
[key: string]:
| Component<any, any, any, any>
| {}
| Component<any, any, any, any, any>
| AsyncComponent<any, any, any, any>
| DefineComponent<any, any, any, any, any, any, any, any, any, any>
}
transitions?: { [key: string]: object }
filters?: { [key: string]: Function }

View File

@ -1115,3 +1115,26 @@ describe('functional w/ object props', () => {
// @ts-expect-error
;<Foo bar={123} />
})
// #12628
defineComponent({
components: {
App: defineComponent({})
},
data() {
return {}
},
provide(): any {
return {
fetchData: this.fetchData
}
},
created() {
this.fetchData()
},
methods: {
fetchData() {
throw new Error('Not implemented.')
}
}
})