Skip to content

Relax switch-case narrowing restrictions#23522

Merged
weswigham merged 3 commits into
microsoft:masterfrom
weswigham:relax-narrowing-restrictions
Apr 27, 2018
Merged

Relax switch-case narrowing restrictions#23522
weswigham merged 3 commits into
microsoft:masterfrom
weswigham:relax-narrowing-restrictions

Conversation

@weswigham
Copy link
Copy Markdown
Member

Fixes #23510

Switch-case exhaustiveness is still handled roughly the same way, however this removes the unit type restriction on switch-case narrowing (which brings it inline with if narrowing).

Comment thread src/compiler/checker.ts Outdated
return !!getPropertyOfType(type, "0" as __String);
}

function isNotUnitTypeOrNever(type: Type): boolean {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: isNeitherUnitTypeNorNever

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But I don't use the neither/nor operator in the body. 👅

@weswigham weswigham merged commit 8c5ad24 into microsoft:master Apr 27, 2018
@weswigham weswigham deleted the relax-narrowing-restrictions branch April 27, 2018 23:30
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 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.

3 participants