nuxt-community / nuxt-property-decorator

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

No overload matches this call. Nuxt hooks #79

Open Soabbar opened 3 years ago

Soabbar commented 3 years ago
<template lang="pug">
  v-container
    v-row
      v-col(cols="12" sm="6" md="6")
        HomePage
</template>

<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'
import HomePage from '@/components/pages/HomePage.vue'

@Component({
  components: {
    HomePage,
  },
  middleware: 'auth',
  async asyncData() {
    return {
      true
    }
  }
})
export default class Index extends Vue {}
</script>

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

Same as this issue https://github.com/nuxt-community/nuxt-property-decorator/issues/58 Nuxt hooks aren't matched.

No overload matches this call. Overload 1 of 2, '(options: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> & ThisType<...>): <VC extends VueClass<...>>(target: VC) => VC', gave the following error. Argument of type '{ components: { AboutUsPage: typeof AboutUsPage; HomePage: typeof HomePage; LandingPage: typeof LandingPage; }; middleware: string; asyncData(): Promise<{ landingTextHead: any; homepageTextHead: any; }>; }' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> & ThisType<...>'. Object literal may only specify known properties, and 'middleware' does not exist in type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> & ThisType<...>'. Overload 2 of 2, '(target: VueClass<Vue>): VueClass<Vue>', gave the following error. Argument of type '{ components: { AboutUsPage: typeof AboutUsPage; HomePage: typeof HomePage; LandingPage: typeof LandingPage; }; middleware: string; asyncData(): Promise<{ landingTextHead: any; homepageTextHead: any; }>; }' is not assignable to parameter of type 'VueClass<Vue>'. Object literal may only specify known properties, but 'components' does not exist in type 'VueClass<Vue>'. Did you mean to write 'component'?

atinux commented 3 years ago

@husayt do you mind looking at this since you closed #58 ?

husayt commented 3 years ago

So it seems #58 is not resolved then, I will reopen it. Same time I can't reproduce this. @Soabbar can you please provide a codesandbox with showing this error?

Johnnyevans32 commented 2 years ago

i need help with this

Johnnyevans32 commented 2 years ago

nothing seems to be working, i already have middleware added in d.ts file for component options

Johnnyevans32 commented 2 years ago

also like this `

<script lang="ts">
import { Component, mixins } from 'nuxt-property-decorator';
import Login from '~/components/Login.vue';
import Web3Mixin from '~/mixins/web3';

@Component({
  components: {
    Login
  }
})
export default class AuthPage extends mixins(Web3Mixin) {
  middleware() {
    return 'authenticated';
  }
  layout() {
    return 'auth';
  }
}
</script>

`

Johnnyevans32 commented 2 years ago

layout works fine but middleware doesnt, can you guys please add middleware as default hooks as it is among nuxt hooks