Skip to content

Commit

Permalink
fix(types): fix type inference when using components option
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 8, 2022
1 parent dc8a68e commit 1d5a411
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 3 additions & 3 deletions types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down Expand Up @@ -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 }
Expand Down
23 changes: 23 additions & 0 deletions types/test/v3/define-component-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
}
}
})

0 comments on commit 1d5a411

Please sign in to comment.