Skip to content

Runloop compatible waitFor type #447

Description

@nwhittaker

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;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions