machty / ember-concurrency-decorators

Task decorators for ember-concurrency 1.x (merged into ember-concurrency 2.0)
MIT License
70 stars 25 forks source link

computed can only be used on accessors or fields error #49

Closed donaldwasserman closed 5 years ago

donaldwasserman commented 5 years ago

I'm not sure how to title this error, becuase I have no idea what's going on.

I have a typescript app I'm trying to update from ember 3.9 => 3.10 e-d 5.2 => 6.0 e-c-t 1.5 => 2.0

So when I'm using

ember 3.10, e-d 6.0, ember-concurrency-decorators1.0.0-beta.2ande-c-t 1.5`, I get the following error:

Uncaught Error: Assertion Failed: @computed can only be used on accessors or fields, attempted to use it with save but that was a method. Try converting it to a getter (e.g. `get save() {}`)

The code this is happening on is:

@dropTask
  public *save(changeset: Changeset, options: any) {
}

Is this an issue here? In typescript? Somewhere else?

abhishek97 commented 5 years ago

@donaldwasserman Facing the same thing. Updating ember 3.8 -> 3.10 . Did you find anything? I'm not using typescript, so not a typescript issue.

donaldwasserman commented 5 years ago

@abhishek97 - I did not, however in a non-typescript context bumping to 3.10, I imported task from ember-concurrency and changed the syntax:

@task // imported from `e-c-decorators`
myTask = function*() {}

to

// imported from `ember-concurrency`
@task(function*() {}) myTask

This seemed to solve all of my issues in the non-typescript context. I haven't had time to check this in typescript yet.

buschtoens commented 5 years ago

Quoting from the README:

Installation

This package only works with Ember Octane, which is currently the latest Ember Beta. You'll need at least ember-cli-babel@^7.7.2 and not use @ember-decorators/babel-transforms, so that you get the Ember.js vanilla stage 1 / legacy decorators. Then install as any other addon:

ember install ember-concurrency-decorators@beta

For non-Octane apps, use the latest version:

ember install ember-concurrency-decorators

When using the beta, which only works with Octane (vanilla stage 1 decorators in Ember.js, aka ember-decorators@6 + ember-decorators-polyfill without @ember-decorators/babel-transforms), you have to use the assignment syntax (@task myTask = function*() {}), as shown in the README.

When using the latest (0.6) version, which only works with stage 2 decorators, you can use the nice @task *myTask() {} syntax.

buschtoens commented 5 years ago

Because of https://github.com/machty/ember-concurrency-decorators/issues/48 it's currently not possible to use the @task *myTask() {} syntax with Octane stage 1 decorators.

donaldwasserman commented 5 years ago

Thanks for clarifying @buschtoens!

I think for many people (or at least me) don't fully understand the differences/usages of which stage of decorators their apps are using. Would you be open to me opening up a PR to clarify usage/requirements in the readme?

buschtoens commented 5 years ago

@donaldwasserman That would be amazing! I'd love it. Thanks!