nuxt / typescript

TypeScript Support for Nuxt 2

Home Page:https://typescript.nuxtjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TS2339: Property 'strategy' does not exist on type 'Auth<any>'

vajihemrp opened this issue · comments

User have logged in successfully throw this.$auth.loginWith('laravelPassportPassword') in nuxtjs with typescript using nuxt/auth module.
https://auth.nuxtjs.org/

Then I tried to get token with this.$auth.strategy.token.get() method. It shows the following error:

`
TS2339:Property 'strategy' does not exist on type 'Auth'.

            })
           .then(() => {
           console.log({ token: this.$auth.strategy.token.get() })
                                           ^^^^^^^^   
           this.$router.push('/')
       })

`

Versions

  • @nuxt/cli : "v2.13.3"
  • nuxtjs/auth-next: "v5"
  • ts: "v4.2"
  • node: v14.15.1

Hi @vajihemrp , this seems to be an issue with nuxtjs/auth-next typings.

strategy may be something that can be accessed on $auth but if the type of $auth is not right, then you'll have this error.

Consider opening an issue on https://github.com/nuxt-community/auth-module