Typescript error when defineComponent is not used on a mixin
I work on vuejs apps that are partly migrated to typescript. Since version 1.8.12 we get new type errors that haven't been there before. Take a look at this code.
App.vue
<template>
<div>
<my-component />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import MyComponent from './components/MyComponent.vue'
import MyMixin from './mixins/MyMixin'
export default defineComponent({
name: 'MyApp',
mixins: [MyMixin],
components: {
MyComponent,
},
})
</script>
MyMixin.js
export default {
methods: {
foobar() {
console.log("foobar");
},
},
};
This gives me the error:
src/App.vue:3:8 - error TS2345: Argument of type '{}' is not assignable to parameter of type 'never'.
I see these errors all over my projects because we use partly typescript, partly javascript. When I insert defineComponent in MyMixin.js, everything works fine. But is this breaking change really intended? Until version 1.8.11 everything worked fine.
You can use this playground link to see the typescript error by yourself: https://codesandbox.io/p/sandbox/blue-wildflower-42ltq6
This seemed to be a bug in vue core.
Likely same issue as #3374, which is also resolved by downgrading to v1.8.11.
any news?
+1
If this problem still happens in the latest version, feel free to open a new issue.