Define this.$auth.user type
See original GitHub issueI’m using typescript and I need to change this.$auth.user
to correct type.
It’s default typed as Record<string, unknown> | null
from @nuxtjs/auth-next/dist/index.d.ts
.
How can I overwrite this type definition?
I tried to create an index.d.ts
file in my src/types
directory with the following content, but it doesn’t work
// Still reading default type
import { Auth } from '@nuxtjs/auth-next/dist'
import { Collaborator } from '~/interfaces/Collaborator'
declare module '@nuxtjs/auth-next' {
interface Vue {
$auth: Auth & { user: Collaborator }
}
}
declare module 'vue/types/vue' {
interface Vue {
$auth: Auth & { user: Collaborator }
}
}
The latter approach gives me this error message:
TS2717: Subsequent property declarations must have the same type.
Property '$auth' must be of type 'Auth', but here has type 'Auth & { user: Collaborator; }'.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:15 (1 by maintainers)
Top Results From Across the Web
authentication - Nuxt Auth - User Data not set - Stack Overflow
As a response I get the token and then the user data is delivered. However, this.$Auth.loggedIn is false and this.$Auth.user is undefined ....
Read more >On this page - Nuxt Auth
This object contains details about authenticated user such as name. You can access it using either $auth or Vuex. // Access using $auth...
Read more >Auth | JavaScript SDK | Firebase JavaScript API reference
When you set the tenant ID of an Auth instance, all future sign-in/sign-up operations will pass this tenant ID and sign in or...
Read more >Authentication - Laravel - The PHP Framework For Web Artisans
At its core, Laravel's authentication facilities are made up of "guards" and "providers". Guards define how users are authenticated for each request. For ......
Read more >AuthComponent - 3.10 - CakePHP Cookbook
Generally, this is done through a username and password, that are checked against a known list of users. In CakePHP, there are several...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m a beginner in typescript, I’m not sure if it’s wrong, but it’s working well in my project
The solution above didn’t work for me. Here’s what worked for me: