emberjs / emberjs/ember-test-waiters

waitFor:

Open
#241 9 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
31
Forks
17
PR merge metrics
No merged PRs in 30d

Description

The Error

```ts
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, label?: string | undefined): Function', gave the following error.
Argument of type 'MyComponentClass' is not assignable to parameter of type 'AsyncFunction'.
Type 'MyComponentClass' provides no match for the signature '(...args: any[]): Promise'.
Overload 2 of 3, '(fn: CoroutineFunction, label?: string | undefined): CoroutineFunction', gave the following error.
Argument of type 'MyComponentClass' is not assignable to parameter of type 'CoroutineFunction'.
Type 'MyComponentClass' provides no match for the signature '(...args: any[]): CoroutineGenerator'.

32 @waitFor
~~~~~~~

Found 2 errors.

```

This is an code that looks like:

```ts
@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:
```diff
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:
```ts
import { waitFor as _waitFor } from '@ember/test-waiters';

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.