ds300 / derivablejs

Functional Reactive State for JavaScript and TypeScript
Apache License 2.0
515 stars 23 forks source link

Typescript error when declare function, that returns promise to Derivable. #75

Open PFight opened 6 years ago

PFight commented 6 years ago

I cant declare function, that returns promise to Derivable. Reason is next:

[Minimal exmaple in playground](https://www.typescriptlang.org/play/#src=interface%20Some%20%7B%0D%0A%20%20then(callback)%3B%0D%0A%7D%0D%0A%0D%0Aasync%20function%20foo()%3A%20Promise%3CSome%3E%20%7B%0D%0A%20%20return%20null%3B%0D%0A%7D%0D%0A%0D%0Aasync%20function%20ok()%3A%20Promise%3Cnumber%3E%20%7B%0D%0A%20%20return%2042%3B%0D%0A%7D)

interface Some {
  then(callback);
}

// Error: the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
async function foo(): Promise<Some> {
  return null;
}

StackOverflow question

Because of that I can't use async/await.

Looks like we should rename then method to chain