vue
vue copied to clipboard
Augmenting `ComponentCustomOptions` with a function causes `TS2769` when using augmention
Version
2.7.14
Reproduction link
Steps to reproduce
- Augment the
ComponentCustomOptions
interface with a new optional member function. Example:funcOption?: (...) => ...
. - Use the new member function in
defineComponent
. ExampledefineComponent({ name: 'CompName', funcOption: (...) => ... })
. - Run a build with type-checking. Example:
npm run build
withvite
andvue-tsc
installed and setup.
Using the repro link:
- Clone the repo
- Run
npm ci
- Run
npm run build
What is expected?
That the build would succeed without error.
What is actually happening?
A TS2769
error results when built. It seems TypeScript is attempting to use the functional component overload rather than one of the normal overloads.
Just discovered the same issue with augment ComponentOptions
as well.
It will work if you change the return value of the funcOption
.
const HomeView = defineComponent({
name: 'HomeView',
components: { TheWelcome },
funcOption: route => {
return {}
}
})