-
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
Don't special case nullable types in isTypeEqualityComparableTo
#59559
base: main
Are you sure you want to change the base?
Don't special case nullable types in isTypeEqualityComparableTo
#59559
Conversation
The TypeScript team hasn't accepted the linked issue #11920. If you can get it accepted, this PR will have a better chance of being reviewed. |
Why not @typescript-bot test it |
Really excited about this one. This has been costing us real bugs uncaught by TS. When we checked undefined but didn't check for null and undefined was literally not even a potential value. |
Hey @jakebailey, the results of running the DT tests are ready. There were interesting changes: Branch only errors:Package: authorizenet
Package: google-protobuf
Package: snapchat-lens-studio
Package: dockerode-compose
Package: google-ads-scripts
Package: mithril
Package: meteor
Package: w3c-web-usb
Package: angular-es
Package: fscreen
Package: node/v16
Package: node-mysql-wrapper
Package: watch
Package: yuka
Package: node/v18
Package: create-subscription
Package: screeps
Package: underscore
Package: jest
Package: node/v20
Package: node
Package: deoxxa-content-type
Package: insight
Package: react-native-modals
Package: smooch
Package: pleasanter-web-script
Package: protractor-beautiful-reporter
Package: d3-selection/v2
Package: xrm/v8
Package: arconnect
Package: chrome-apps
Package: knockout
Package: node-localstorage
Package: webappsec-credential-management
Package: d3-selection
Package: nodemailer
Package: webmidi
Package: bootstrap-fileinput
Package: rdf-ext
Package: vinyl
Package: react-bootstrap-typeahead
Package: 11ty__eleventy-img
Package: express-fileupload
Package: bluebird
Package: chai
Package: d3-selection/v1
|
@jakebailey Here are the results of running the user tests with tsc comparing Something interesting changed - please have a look. Details
|
@jakebailey Here are some more interesting changes from running the user tests suite Details
|
@jakebailey Here are some more interesting changes from running the user tests suite Details
|
@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 Something interesting changed - please have a look. Details
|
@jakebailey Here are some more interesting changes from running the top 400 repos suite Details
|
@jakebailey Here are some more interesting changes from running the top 400 repos suite Details
|
@jakebailey Here are some more interesting changes from running the top 400 repos suite Details
|
@jakebailey Here are some more interesting changes from running the top 400 repos suite Details
|
@jakebailey Here are some more interesting changes from running the top 400 repos suite Details
|
@jakebailey Here are some more interesting changes from running the top 400 repos suite Details
|
@jakebailey Here are some more interesting changes from running the top 400 repos suite Details
|
@jakebailey Here are some more interesting changes from running the top 400 repos suite Details
|
heh, at least it has been proven to be quite breaking 😅 so I guess now the question is if you'd be willing to pick this up as a new opt-in flag outside of the regular |
I briefly looked over the issues the bot has found and it seems to me that it found loads of code that shouldn't be there? |
The first link I opened led to Effect-TS/effect#3435, so that's a good sign, but wow that's a lotta damage |
For javascript-obfuscator, since it was interesting:
|
"just" doesn't give this credit 😅 most people don't use this (including the compiler's code ;p). This kind of break will be the most painful but it can usually be easily refactored to |
Yeah "just" was doing a lot of work in that sentence 😅 |
closes #11920
Potential downsides of this PR:
if (window.matchMedia) {}
is already an error)noUncheckedIndexedAccess
. This can easily be mitigated by including| undefined
in those index signatures - if the user wants to check against missing values then it makes sense to include those nullable types in the index signatures themselves. However, perhaps the biggest issue here is related to how people might want to cross-reference different-sized arraysNote that the above downsides are not arguments in favor of special casing
null
. However, a more general "defensive programming" argument could still be used in its favorAdvantages of this PR:
===
that is easier to understand for people. The current logic is a special case and many people don't know that it is one@RyanCavanaugh mentions:
I'm not sold, personally, on introducing a new flag to enable this behavior. Would it even be a
strict
flag? or one of the other opt-ins likenoUncheckedIndexedAccess
?@DanielRosenwasser mentions:
I'm also not sure if this is needed. Note that both comments are pretty old at this point and the TS landscape and user expectations changed a lot since then.
I don't mind implementing any of the above. This PR is meant as a conversation starter - I'd expect the final decision about this will require a design meeting either way and I can only address the async feedback received based on that.
I also expect user tests to reveal this to be quite breaking and at the same time, it might be hard to judge if those are good breaks or not. I could categorize them and count them by those categories to help aid the final decision though. Regardless, it will be interesting to see how breaking it turns out to be in its current form.
Open questions:
{} == null
(and similar) be disallowed too? I think it's OK to allow this even if the left/right types wouldn't pass comparability + coercion check