vuex-typescript-interface icon indicating copy to clipboard operation
vuex-typescript-interface copied to clipboard

Reference to Other Modules

Open dougalg opened this issue 5 years ago • 2 comments
trafficstars

In theory, given that the modules are not namespaced, I should be able to access them from anywhere, so give:

interface UserStore {
	[SET_USER](user: User): void
	[details: number]: User;
}

interface CurrentUserStore {
	currentUserId: number,

	[SET_CURRENT_USER](user_id: number): void
	[CLEAR_CURRENT_USER](): void

	[LOG_IN](payload: LoginRequest): Promise<User|ApiLoginError>
}

interface MyStore {
	modules: {
		user: UserStore,
		currentUser: CurrentUserStore,
	}
}

The LOG_IN action should be able to access SET_USER, but it doesn't seem to be available to me in the typings. Maybe I'm just missing something here?

dougalg avatar May 07 '20 09:05 dougalg

I was able to get it to work by adding { root: true }. But that shouldn't be necessary, right?

dougalg avatar May 07 '20 09:05 dougalg

That's true - thanks for bringing it up

ClickerMonkey avatar Sep 18 '20 17:09 ClickerMonkey