vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.73k stars 385 forks source link

Typescript error when defineComponent is not used on a mixin #3608

Open prof-schnitzel opened 11 months ago

prof-schnitzel commented 11 months ago

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

so1ve commented 11 months ago

This seemed to be a bug in vue core.

IGx89 commented 10 months ago

Likely same issue as #3374, which is also resolved by downgrading to v1.8.11.

juztinlazaro commented 6 months ago

any news?

Klapeks commented 2 months ago

+1