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

Type error using useTask with ember-concurrency 1.x and ember-concurrency-async #297

Closed
steveszc opened this issue Dec 3, 2021 · 2 comments

Comments

@steveszc
Copy link

steveszc commented Dec 3, 2021

Running into a type error when using some combination of [email protected], ember-concurrency-async, ember-concurrency-decorators, and ember-resources' useTask. I not sure exactly what in there is causing the issue though.

"ember-concurrency": "1.3.0",
"ember-concurrency-async": "0.3.2",
"ember-concurrency-decorators": "2.0.3",
"ember-concurrency-ts": "0.3.1",
"ember-resources": "3.2.1"

When doing something like this:

import { dropTask } from 'ember-concurrency-decorators';
import { inject as service } from '@ember/service';
import { taskFor } from 'ember-concurrency-ts';
import { tracked } from '@glimmer/tracking';
import { useTask } from 'ember-resources';

export default class extends Service {
  @tracked foodId = 'pizza';

  foodResource = useTask(this, taskFor(this.load), () => [this.foodId]);

  @dropTask
  async loadFood() {
    let food = await fetchFood();
    return food;
 }
}

I get the following type error:

Argument of type 'TaskForAsyncTaskFunction<() => Promise<Food>>' is not assignable to parameter of type 'TaskIsh<Food, Data[]>'.
  The types returned by 'perform(...).cancel(...)' are incompatible between these types.
    Type 'void' is not assignable to type 'Promise<void>'.

Seems like this could be fixed by updating the type for cancel here to allow void

NullVoxPopuli added a commit that referenced this issue Dec 5, 2021
NullVoxPopuli added a commit that referenced this issue Dec 5, 2021
Issue: #297

Resolves this issue:
```
Argument of type 'TaskForAsyncTaskFunction<() => Promise<Food>>' is not assignable to parameter of type 'TaskIsh<Food, Data[]>'.
  The types returned by 'perform(...).cancel(...)' are incompatible between these types.
    Type 'void' is not assignable to type 'Promise<void>'.
```
NullVoxPopuli added a commit that referenced this issue Dec 5, 2021
Issue: #297

Resolves this issue:
```
Argument of type 'TaskForAsyncTaskFunction<() => Promise<Food>>'
  is not assignable to parameter of type 'TaskIsh<Food, Data[]>'.

  The types returned by 'perform(...).cancel(...)' are incompatible between these types.
    Type 'void' is not assignable to type 'Promise<void>'.
```
NullVoxPopuli added a commit that referenced this issue Dec 5, 2021
Issue: #297

Resolves this issue:
```
Argument of type 'TaskForAsyncTaskFunction<() => Promise<Food>>'
  is not assignable to parameter of type 'TaskIsh<Food, Data[]>'.

  The types returned by 'perform(...).cancel(...)' are incompatible between these types.
    Type 'void' is not assignable to type 'Promise<void>'.
```
NullVoxPopuli added a commit that referenced this issue Dec 5, 2021
NullVoxPopuli added a commit that referenced this issue Dec 5, 2021
Issue: #297

Resolves this issue:
```
Argument of type 'TaskForAsyncTaskFunction<() => Promise<Food>>'
  is not assignable to parameter of type 'TaskIsh<Food, Data[]>'.

  The types returned by 'perform(...).cancel(...)' are incompatible between these types.
    Type 'void' is not assignable to type 'Promise<void>'.
```
NullVoxPopuli added a commit that referenced this issue Dec 5, 2021
@NullVoxPopuli
Copy link
Owner

Is this still an issue? Looks like there were some commits related to this?

@NullVoxPopuli
Copy link
Owner

Gonna close this for now -- feel free to re-open of there are still issues!

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

2 participants