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

Runloop compatible waitFor type #447

Open
nwhittaker opened this issue Feb 17, 2023 · 0 comments
Open

Runloop compatible waitFor type #447

nwhittaker opened this issue Feb 17, 2023 · 0 comments

Comments

@nwhittaker
Copy link

Is it feasible to provide a type for waitFor that is compatible with Ember's runloop functions?

Looking to do something like:

schedule('afterRender', waitFor(async () => {  }))

However this currently throws a type error:

Argument of type 'Function' is not assignable to parameter of type 'AnyFn'.
  Type 'Function' provides no match for the signature '(...args: any[]): unknown'. ts(2345)

Adding this function override appears to minimally be enough to clear up the issue:

export default function waitFor(fn: AsyncFunction<any[], any>, label?: string): (...args: any[]) => unknown;

A possibly more robust solution:

export default function waitFor(fn: AsyncFunction<unknown[], unknown>, label?: string): (...args: unknown[]) => unknown;
@nwhittaker nwhittaker changed the title Runloop compatible types Runloop compatible waitFor type Feb 17, 2023
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