ember-concurrency icon indicating copy to clipboard operation
ember-concurrency copied to clipboard

New task syntax is should not return void

Open cah-brian-gantzler opened this issue 6 months ago • 0 comments

The new way to define a task is

waitAFewSeconds = task({drop: true}, async () => {
  this.status = 'Gimme one second...';
  await timeout(1000);
  this.status = 'Gimme one more second...';
  await timeout(1000);
  this.status = "OK, I'm done.";
});

The return value from the task function is assigned to waitAFewSeconds

However the intellij editor is reading the task function is defined at https://github.com/machty/ember-concurrency/blob/master/packages/ember-concurrency/src/index.d.ts#L849 as returning a void

export function task(target: Object, propertyKey: string): void;

Why does the editor think that this definition is the correct one to use. While this first param is a hash (Object), the second param is a function, not a string.

Do not know enough about type script and all the definitions. Posting here thinking that there may be something incomplete in the index.d.ts that is leading the editor astray.

If you remove the options { drop: true} the editor thinks it is the definition here https://github.com/machty/ember-concurrency/blob/master/packages/ember-concurrency/src/index.d.ts#L841 which does not return a void, but I do not know why it chooses this one either.

Looking at the code all the comments above are showing the decorator. Is there something more in the typescript defs that are needed to convert the use a decorator to the new syntax?

cah-brian-gantzler avatar Aug 06 '24 20:08 cah-brian-gantzler