nuxt-community / nuxt-property-decorator

Property decorators for Nuxt (base on vue-property-decorator)
https://github.com/kaorun343/vue-property-decorator
MIT License
400 stars 34 forks source link

No overload matches this call. When using middleware #58

Closed mewis closed 4 years ago

mewis commented 5 years ago

I have the following component...

<template>
  <div>
    home
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'

@Component({
  middleware: ['auth']
})
export default class HomePage extends Vue {}
</script>

<style lang="scss" scoped></style>

the middleware hook is doing as expected but my ide throws the error...

No overload matches this call. Overload 1 of 2, '(options: ComponentOptions<Vue, DefaultData, DefaultMethods, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>> & ThisType): <VC extends VueClass<...>>(target: VC) => VC', gave the following error. Argument of type '{ middleware: string[]; }' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData, DefaultMethods, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>> & ThisType'. Object literal may only specify known properties, and 'middleware' does not exist in type 'ComponentOptions<Vue, DefaultData, DefaultMethods, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>> & ThisType'. Overload 2 of 2, '(target: VueClass): VueClass', gave the following error. Argument of type '{ middleware: string[]; }' is not assignable to parameter of type 'VueClass'. Object literal may only specify known properties, and 'middleware' does not exist in type 'VueClass'.

I cant see anywhere in the docs that covers adding specific types for the decorator.

Is there a extra step in setting this up that I am missing?

husayt commented 4 years ago

I just released v 2.7.1 of the library which fixes many issues. I will close thise issue, if this is still an issue please let me know