{{ message }}
[compiler] Allow strict comparisons of ref-accessing callbacks - #37528
Open
kolvian wants to merge 1 commit into
Open
[compiler] Allow strict comparisons of ref-accessing callbacks#37528kolvian wants to merge 1 commit into
kolvian wants to merge 1 commit into
Conversation
kolvian
force-pushed
the
fix-37521-ref-comparisons
branch
from
September 6, 2026 08:24
a4233ba to
726e34e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes #37521. Previously, strict equality comparisons (ie.
===or!==) with ref-accessing callback functions as operands would be flagged by ESLint as accessing ref values at render time. Since strict equality comparisons don't call the operand functions, it is safe to perform these comparisons at render time, so I add narrow support to===and!==, while still rejecting operands read fromref.current. In the future, this could be expanded to includetypeofand other checks as well. I also added 8 tests for thoroughness:4 compiler fixtures, each with a generated
.expect.mdsnapshot:4 ESLint 8 integration cases:
How did you test this change?
All tests pass,
yarnpasses,yarn flow dom-nodepasses. I also added a specific regression test for this change, which runs something similar to this:Previously, this would be flagged by ESLint. You can run this yourself by running: