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

New task syntax is should not return void #576

Open
cah-brian-gantzler opened this issue Aug 6, 2024 · 0 comments
Open

New task syntax is should not return void #576

cah-brian-gantzler opened this issue Aug 6, 2024 · 0 comments

Comments

@cah-brian-gantzler
Copy link

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?

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

1 participant