Skip to content

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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot narrow the optional properties to T properly through (T | undefined) => T if --strictOptionalProperties=true

5 participants