Skip to content
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

Better assignability check for IteratorResult<T,U> #17285

Closed
skishore opened this issue Jul 19, 2017 · 2 comments
Closed

Better assignability check for IteratorResult<T,U> #17285

skishore opened this issue Jul 19, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@skishore
Copy link

I'm opening this bug to discuss a blocker for #2983 that seems significant enough to merit discussion on its own. In the course of trying to fix that issue, I found that Typescript cannot assign the type:

{done: boolean, value: number}

to the type:

{done: false, value: number} | {done: true, value: any}

What's going on here is that assignment from a non-union type T to a union type A | B is currently only allowed if T can be assigned to A or to B. However, in this particular case, casework on the type T shows that is indeed a subtype of A | B.

I don't propose to fix this problem in full generality. In fact, that seems pretty much infeasible to me, as I think we can express arbitrary SAT instances as instances of this problem. However, would people be okay with an improvement to the assignment relation specific to this IteratorResult case?

@skishore skishore changed the title Improved assignability checks for boolean-discriminated unions Improved assignability checks for generalized IteratorResults Jul 19, 2017
@skishore skishore changed the title Improved assignability checks for generalized IteratorResults Improved assignability checks for general IteratorResults Jul 19, 2017
@skishore skishore changed the title Improved assignability checks for general IteratorResults Better assignability check for IteratorResult<T,U> Jul 19, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Aug 23, 2017

Duplicate of #2983 and #11375

@mhegazy mhegazy added the Duplicate An existing issue was already created label Aug 23, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 7, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Sep 7, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants