Skip to content

Bidirectional comparable relation for primitive types #19926

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 3 commits into from
Nov 11, 2017

Conversation

ahejlsberg
Copy link
Member

This PR makes the comparable relation bidirectional for primitive types. For example, the following previously was an error but is now permitted:

declare const x: { a: 1, b: string };
declare const y: { a: number, b: 'a' };

x === y;  // Now ok, previously was error

@@ -0,0 +1,8 @@
// @strict: true

// Verify that properties can vary idependently in comparable relationship
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo:independently

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how similar the logic in two replaced callsites for isSimpleTypeRelatedTo is, it'd be nice to see the logic moved into a helper function; but it's not required, since it's only duplicating code in two places. 🤷‍♂️

@ahejlsberg ahejlsberg merged commit b8fbf88 into master Nov 11, 2017
@ahejlsberg ahejlsberg deleted the improvePrimitiveComparable branch November 11, 2017 17:15
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants