Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MutationAction not working with RemoteData union type #370

Open
FranzBusch opened this issue Jul 6, 2021 · 0 comments
Open

MutationAction not working with RemoteData union type #370

FranzBusch opened this issue Jul 6, 2021 · 0 comments

Comments

@FranzBusch
Copy link

I am trying to use vuex-module-decotrators in conjunction with union types like RemoteData; however, I am getting a type error when doing so. My RemoteData union type looks like this

export type NotAsked = {
    type: "NotAsked";
}
  
  export type Loading = {
    type: "Loading";
  }
  
  export type Success<T> = {
    type: "Success";
    data: T;
  }
  
  export type Failure<E> = {
    type: "Failure";
    error: E;
  }
  
  export type RemoteData<T, E> = Success<T> | NotAsked | Loading | Failure<E>;

And my usage inside a store looks like this

@Module({
  namespaced: true,
  dynamic: true,
  store: store,
  name: 'foo',
})
class FooModule extends VuexModule {
  bar: RemoteData<string, UserError> = Success("");

  @MutationAction
  async getBar() {
    return {
      bar: NotAsked
    }
  }
}

The type error I am seeing is this:

Type 'RemoteData<string, UserError>' is not assignable to type 'NotAsked | null'.

Is there anything I can do with vuex-module-decorators to make this work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant