8000 Add special-case handling for multiplication by zero by kungfooman · Pull Request #3 · skeate/TypeScript · GitHub
[go: up one dir, main page]

Skip to content

Add special-case handling for multiplication by zero#3

Open
kungfooman wants to merge 1 commit intoskeate:mainfrom
kungfooman:mul-zero
Open

Add special-case handling for multiplication by zero#3
kungfooman wants to merge 1 commit intoskeate:main< 8000 span class="prc-TooltipV2-Tooltip-tLeuB" data-direction="s" role="tooltip" aria-hidden="true" id="_R_1njahd_">skeate/TypeScript:mainfrom
kungfooman:mul-zero

Conversation

@kungfooman
Copy link

This PR introduces a special-case check in checker.ts to ensure that multiplying any numeric type by the literal 0 always results in the literal type 0. This aligns with mathematics and should speed up type resolution for e.g. unions - why do all the distribution in e.g. Multiply<1 | 2, 0> when it will be 0 anyway?

TLDR: we can just short-circuit in case of zero multiplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0