Skip to content

Change assignability to account for type parameters extending unions #2778

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

Merged
merged 4 commits into from
Apr 15, 2015

Conversation

JsonFreeman
Copy link
Contributor

Fixes #2576.

Right now, there are only three ways that a type parameter S can be assignable to a type T:

  • T is a type parameter and S is directly or indirectly constrained to T
  • T is an object type, and the base constraint of S is an object type (they are compared structurally).
  • T is a union type that includes S as a constituent.

What is missing is a case that handles the base constraint of S being a union type. My proposal in this case is that S should be assignable to T if the base constraint of S is assignable to T.

This necessitates an accompanying change to the spec.

@ahejlsberg
Copy link
Member

👍

JsonFreeman added a commit that referenced this pull request Apr 15, 2015
Change assignability to account for type parameters extending unions
@JsonFreeman JsonFreeman merged commit b1acce0 into master Apr 15, 2015
@JsonFreeman JsonFreeman deleted the typeParameterUnionAssignability branch April 15, 2015 22:53
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue using union type with generic
3 participants