michaelolof / vuex-class-component

A Type Safe Vuex Module or Store Using ES6 Classes and ES7 Decorators written in TypeScript.
217 stars 21 forks source link

[Bug] Actions force you to be async #67

Open robertofd1995 opened 4 years ago

robertofd1995 commented 4 years ago

I am creating a new project with Nuxt and I have added your library (thanks for your work by the way ;) ) but there is a problem with the Action decorator.

It force me all the time to return promises even if I don't want to.

For example in this piece of code:

  @action test() {
    console.log('IP UP UASD!')
    return 1
  }

I get the following error:

Captura de pantalla 2020-04-20 a las 9 44 38

So even If I don't put the async there and I ignore the error suppressing it with // @ts-ignore, when I use it in my component I get a promise, and again I am force to put async and await inside the method of the component without sense.

I guess this is fault of the types, but I try to take a look and see If I could create a pull request to fix it but I am not that proficient with Typescript and how the decorators work.

How can I make it work with as a non async action?

Thanks in advance.

samuil4 commented 4 years ago

I do have the same problem...

nunonux commented 4 years ago

Vuex actions always returns a promise, it's in the documentation, so I think it's because of that.