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

Make identity comparison reflexive across unions or intersections of the same type #60868

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichaelMitchell-at
Copy link

Please verify that:

#60726 (comment) points out why some type testing libraries define equality with a definition like:

type Equals<A, B> = (<T>() => T extends (B & T) | T ? 1 : 0) extends (<T>() => T extends (A & T) | T ? 1 : 0) ? true : false;

rather than just

type Equals<A, B> = (<T>() => T extends B ? 1 : 0) extends (<T>() => T extends A ? 1 : 0) ? true : false;

which is that types like {a: 1} are not considered identical to types like {a: 1} & {a: 1} and {a: 1} | {a: 1}.

The latter definition of Equals is required to enable #60726, so I've made this PR to eliminate the need for the former definition of Equals.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Dec 29, 2024
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@MichaelMitchell-at MichaelMitchell-at force-pushed the reflexive_identity_comparisons branch from 70d3914 to 7b7a9b2 Compare December 29, 2024 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

2 participants