Skip to content

Promise.then does not accept callback that returns T | Promise<S> #15599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rkirov opened this issue May 5, 2017 · 1 comment
Closed

Promise.then does not accept callback that returns T | Promise<S> #15599

rkirov opened this issue May 5, 2017 · 1 comment
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@rkirov
Copy link
Contributor

rkirov commented May 5, 2017

TypeScript Version: 2.3.1

Code

declare let p: Promise<void>;
declare let p2: Promise<string>;

let p3 = p.then(() => Math.random() ? 0 : p2);

Expected behavior:
Code is accepted and type of p3 is Promise<string|number>.

Actual behavior:
Type Error: Argument of type '() => Promise<string> | 0' is not assignable to parameter of type '(value: void) => string | PromiseLike<string>'.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label May 24, 2017
@RyanCavanaugh RyanCavanaugh added Design Limitation Constraints of the existing architecture prevent this from being fixed and removed Needs Investigation This issue needs a team member to investigate its status. labels Sep 18, 2019
@RyanCavanaugh
Copy link
Member

Promise<void> remains problematic 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

2 participants