NullVoxPopuli / ember-resources

An implementation of Resources. Supports ember 3.28+

Home Page:https://github.com/NullVoxPopuli/ember-resources/blob/main/docs/docs/README.md

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

steveszc opened this issue · comments

Running into a type error when using some combination of ember-concurrency@1.x, 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

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

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