-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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: fix any() for symbols and bigints (#10179) #10223
Conversation
6f01978
to
cd23c45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left a note on the null
@@ -46,13 +46,22 @@ class Any extends AsymmetricMatcher<any> { | |||
} | |||
|
|||
if (this.sample == Object) { | |||
return typeof other == 'object'; | |||
return typeof other == 'object' && other !== null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is kinda breaking, null
is and Object in JS after all. Please revert
I've added a commit reverting the change to If |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Adds clauses to
expect
'sAny.asymmetricMatch()
to handleSymbol
andBigInt
analogously to other primitives, i.e., usingtypeof
instead ofinstanceof
. This makesexpect.any()
's behavior more consistent across primitive types.Adds a clause to
Any.asymmetricMatch()
to excludenull
fromexpect.any(Object)
. This makesexpect.any()
's behavior more consistent with its documentation;null
is not created with theObject
constructor, and so should not be matched.Closes #10179.
Test plan
Added checks to the list in
asymmetricMatchers.test.ts
test('Any.asymmetricMatch())'
to cover the changed behavior.