Repository: TypeScript
Issue: Unable to return ElementFinder from an async function in TS 3.9
Labels: Needs Investigation

<!-- 🚨 STOP 🚨 STOP 🚨 STOP 🚨

Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section!

Please help us by doing the following steps before logging an issue:
  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues
  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ

Please fill in the *entire* template below.
-->

<!--
Please try to reproduce the issue with the latest published version. It may have already been fixed.
For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly
-->
**TypeScript Version:**  3.9.2

<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**Search Terms:**
`The return type of an async function must either be a valid promise or must not contain a callable 'then' member.(1058)`

**Code**

```ts
export declare class ElementFinder {
    then?: (fn: (value: any) => any, errorFn?: (error: any) => any) => Promise<any>;
}

export declare class ElementArray{
    first(): ElementFinder;
}

export async function assertSingleElement( // error: The return type of an async function must either be a valid promise or must not contain a callable 'then' member.(1058)
    array: ElementArray,
): Promise<ElementFinder> {

    //await something up here so require async function

    return array.first() as any;
}
```
This code works in 3.8.

**Expected behavior:**
We should be able to compile the above code or at least tell TS to ignore the error and compile anyway.

**Actual behavior:**
There is no way that I could find to return an object with a `then` function from an async function.

**Playground Link:**
https://www.typescriptlang.org/play?ts=3.9.2#code/KYDwDg9gTgLgBAE2AYwDYEMrDm9BnPOAUVWAFtgA7GAMQEtKko4BvAKDk7hgAsqB+AFxwAFADNKwkQDd0qAK7Bh6SgE8AlHAC8APjgrVAGjjAoUaDUpDRp81GVrNu-Y+16ACubJ08wADwGOgDcbAC+bGygkLCIKBhYOBgExKQU1ACCZuiq7FxwYnRQeDAi6sIk5FS0DEwh4ZHg0PD4qpTI+fJtMHQQlPoEpjAAygwA5qQVaSUcXJhQ2eWpVZnzRmxlcJ4Q3r5+k1X0jKZ67DOcAPTn6ADu6HTweNvAvGNw8mBwfAmPcFgAjvJCtgWm0Ol0epQInksDB5FA+nNsgA6ApFEqafAuVR1IA

This is ultimately an issue with Protractor. The "workaround" is to edit the d.ts files in node_modules which for most build chains is not an option at all. Related issue:
https://github.com/angular/protractor/issues/3831

In the above function I am trying to return an `ElementFinder` object from an async function. `ElementFinder` is a badly typed Promise type thing but I don't want the ElementFinder to be resolved, I want an unresolved ElementFinder to be returned and to be used in the calling function. It seems that the `then` function is breaking TS and there doesn't seem to be any way to trick TS into allowing this.
This worked fine in 3.8 but breaks in 3.9 and currently preventing us from upgrading to Angular 10.

How to I trick TS into allowing this?