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

Ensure singleton types always compare identical #44565

Merged
merged 3 commits into from
Jun 13, 2021
Merged

Ensure singleton types always compare identical #44565

merged 3 commits into from
Jun 13, 2021

Conversation

ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented Jun 12, 2021

This PR ensures the "singleton" types (any, unknown, string, number, boolean, bigint, symbol, void, undefined, never, and object) always compare identical when their type kind matches, regardless of type object identity. This in particular ensures that the undefined used to represent a missing property compares identical to the "regular" undefined.

The PR also ensures that TypeFlags.Boolean is consistently set on any union of the boolean literal values true and false. We weren't setting this flag on type alias declarations for true | false.

Fixes #44388.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jun 12, 2021
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.

A testcase for the BooleanLiteral parts of this change (so we avoid regressing) would be nice.

@awerlogus
Copy link

Will this also fix #44453?

@ahejlsberg
Copy link
Member Author

@weswigham Except for error messages in one case (for an indexed access type [number][boolean] where we just report an error for boolean instead of true and false separately) we have no compiler behaviors that change based on whether TypeFlags.Boolean is set or not, so adding a test isn't super useful. My main concern was external dependencies such as linters.

@ahejlsberg ahejlsberg merged commit 6a1623d into main Jun 13, 2021
@ahejlsberg ahejlsberg deleted the fix44388 branch June 13, 2021 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
4 participants