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

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

Closed
donaldwasserman opened this issue May 15, 2019 · 6 comments
Closed

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

donaldwasserman opened this issue May 15, 2019 · 6 comments

Comments

@donaldwasserman
Copy link

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-decorators 1.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
Copy link

abhishek97 commented May 28, 2019

@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
Copy link
Author

@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
Copy link
Collaborator

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
Copy link
Collaborator

buschtoens commented May 28, 2019

Because of #48 it's currently not possible to use the @task *myTask() {} syntax with Octane stage 1 decorators.

@donaldwasserman
Copy link
Author

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
Copy link
Collaborator

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

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

3 participants