Skip to content

waitFor:  #241

@NullVoxPopuli

Description

@NullVoxPopuli

The Error

error TS1236: The return type of a property decorator function must be either 'void' or 'any'.
  Unable to resolve signature of property decorator when called as an expression.

32   @waitFor
     ~~~~~~~~
error TS2769: No overload matches this call.
  Overload 1 of 3, '(fn: AsyncFunction<any[], any>, label?: string | undefined): Function', gave the following error.
    Argument of type 'MyComponentClass' is not assignable to parameter of type 'AsyncFunction<any[], any>'.
      Type 'MyComponentClass' provides no match for the signature '(...args: any[]): Promise<any>'.
  Overload 2 of 3, '(fn: CoroutineFunction<any[], any>, label?: string | undefined): CoroutineFunction<any[], any>', gave the following error.
    Argument of type 'MyComponentClass' is not assignable to parameter of type 'CoroutineFunction<any[], any>'.
      Type 'MyComponentClass' provides no match for the signature '(...args: any[]): CoroutineGenerator<any>'.

32   @waitFor
      ~~~~~~~


Found 2 errors.

This is an code that looks like:

  @task
  @waitFor
  myTask = taskFor(async () => {
   // ...

using:

  • ember-concurrency-ts
  • ember-concurrency-async
  • ember-concurrency-decorators
  • ember-concurrency @ v1.x

I believe the fix would be to make this change:

  export default function waitFor(
    target: object,
    _key: string,
    descriptor: PropertyDescriptor,
    label?: string
- ): PropertyDescriptor;
+ ): any;

This is with TypeScript 4.1.2

I've worked around this via:

import { waitFor as _waitFor } from '@ember/test-waiters';

export const waitFor = (_waitFor as unknown) as PropertyDecorator;

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