You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use data from the auth module, in the gallery module (to get the current signed in user)
However TS is complaining about the auth variable inside my GalleryActions class TS2564: Property 'auth' has no initializer and is not definitely assigned in the constructor.
Am I missing something? Thank you.
auth module
class AuthState {
user?: User
authenticationError?: string
}
export const auth = new Module({
state: AuthState,
getters: AuthGetters,
mutations: AuthMutations,
actions: AuthActions
})
gallery module
import {auth as authModule} from './auth'
class GalleryActions extends Actions<GalleryState, GalleryGetters, GalleryMutations, GalleryActions> {
auth: Context<typeof authModule> // <--------------------- errored line
$init(store: Store<any>): void {
this.auth = authModule.context(store)
}
}
The text was updated successfully, but these errors were encountered:
import{authasauthModule}from'./auth'classGalleryActionsextendsActions<GalleryState,GalleryGetters,GalleryMutations,GalleryActions>{auth!: Context<typeofauthModule>// Just add "!" after the module name$init(store: Store<unknown>): void{this.auth=authModule.context(store)}}
I would like to use data from the auth module, in the gallery module (to get the current signed in user)
However TS is complaining about the auth variable inside my GalleryActions class
TS2564: Property 'auth' has no initializer and is not definitely assigned in the constructor.
Am I missing something? Thank you.
auth module
gallery module
The text was updated successfully, but these errors were encountered: