-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Fix generic nullable checks #59437
base: main
Are you sure you want to change the base?
Fix generic nullable checks #59437
Conversation
@typescript-bot test it |
@ahejlsberg Here are the results of running the user tests with tsc comparing Everything looks good! |
Hey @ahejlsberg, the results of running the DT tests are ready. Everything looks the same! |
@ahejlsberg Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@ahejlsberg Here are the results of running the top 400 repos with tsc comparing Something interesting changed - please have a look. Details
|
The new errors in the top 400 repos tests are all the same: Functions that compare values of unconstrained generic types. Our existing behavior is to permit such comparisons--we only error when the types have constraints that explicitly include We should decide if we think erroring on generic operands that are possibly |
We're going to wait for 5.7 on this one since it is technically a breaking change. |
This PR builds on #59415 to implement the following in aggregate:
obj[key]
, whenobj
andkey
both have generic types we no longer require the constraint ofobj
to be a non-nullable type. The rationale for this change is that whenkey
is a valid property name forobj
, it must be becauseobj
is of a non-nullable type, as discussed here.unknown
to possibly benull
orundefined
in--strictNullChecks
mode. Previously, we would only consider generic types with constraints includingnull
orundefined
to possibly be nullable.Fixes #50603.