ds300 / ds300/derivablejs

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

Open
#75 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
518
Forks
23
PR merge metrics
No merged PRs in 30d

Description

I cant declare function, that returns promise to [Derivable](https://ds300.github.io/derivablejs/#derivable-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 {
return null;
}

[StackOverflow question](https://stackoverflow.com/questions/47111363/typescript-error-when-function-return-type-is-promise-then-void)

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

Looks like we should rename `then` method to `chain`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.