ClickerMonkey / vuex-typescript-interface

Adding magical type safety to Vuex without additional code
MIT License
44 stars 4 forks source link

Reference to Other Modules #15

Open dougalg opened 4 years ago

dougalg commented 4 years ago

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 commented 4 years ago

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

ClickerMonkey commented 3 years ago

That's true - thanks for bringing it up