ember-cli-typescript
ember-cli-typescript copied to clipboard
ember-concurrency-decorators typehinting.
ember-concurrency-decorators lacks proper typehinting in the IDE.

The limitations are clear. Perhaps there can be a solution in the future. At the least we could document this behavior.
Elaboration: this happens when you write a decorated task like this:
import Component from '@ember/component';
import { action } from '@ember-decorators/object';
import { task } from 'ember-concurrency-decorators';
export default class MyComponent extends Component {
@task
*fetchRecords() {
// whatever behavior
}
@action
doSomething() {
this.fetchRecords.perform();
}
The problem is that the type of *fetchRecords from TS' perspective is a generator function; decorators are not currently allowed to change the type of the thing they decorate. But this decorator is in fact wrapping the generator function in a Task type which has a perform method, so the type as TS sees it and the type as it behaves at runtime are different.
Related to https://github.com/machty/ember-concurrency-decorators/issues/41
This was resolved via a series of workarounds (hacks? But of a respectable variety!) in ember-concurrency. Thanks for the original reports, folks!