-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Fix #61429: Fast arithmetic type check for type-parameters upper-bounded by bigint fixed
#61571
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
base: main
Are you sure you want to change the base?
Fix #61429: Fast arithmetic type check for type-parameters upper-bounded by bigint fixed
#61571
Conversation
|
@microsoft-github-policy-service agree |
ae470a1 to
1390f5f
Compare
1390f5f to
71d535a
Compare
|
@jakebailey Hi, I'm not sure if you missed the new approach I took. I found a more appropriate Apologies if you were already aware, I'm sure you have more important tasks to attend to for TypeScript! |
|
@typescript-bot test it |
|
@jakebailey Here are the results of running the user tests with tsc comparing Everything looks good! |
|
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
|
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
Fixes #61429
The
maybeTypeOfKindfunction is a simpler version of full type-checking which is used by arithmetic. Previously it was used to determine whether arithmetic operations such as+,<<, and~were acting onnumbertypes orbiginttypes.Note that these type checks are somewhat complicated by a desire to preserve unsoundness:
any * anyshould benumber, rather than the (sound but exceedingly impractical)number | bigint.Previously, the
maybeTypeOfKindfunction did not returntruewhen an operand has a typeT, regardless of the bounds ofT. This meant that whenmaybeTypeOfKindis passedT extends bigintandbigint, it returnedfalse.This caused expressions like
a & bto be assigned the "default" typenumberinstead ofbigint.To fix this issue, I updated the checks to instead use
maybeTypeOfKindConsideringBaseConstraint. I suspect that some of the other uses ofmaybeTypeOfKindhave similar issues, but if so they seem much more subtle and I wasn't able to construct any suspicious tests for them.I added the
bigintSubtypingTypeParametertest which includes a variety of unary and binary operators acting on suchT extends bigintvalues.This is my first PR, so apologies if I'm missing something important.