shallow
function does not work properly for some objects
#3204
Unanswered
monsonjeremy
asked this question in
Bug report
Replies: 2 comments 5 replies
-
@monsonjeremy you are checking ts on a js file? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Interesting. Is it the same if we use the string key? shallow({ 'a': undefined }, { 'b': {x: 1}})
// true? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Description
I was testing
shallow
because I was running into issues where sometimes I wasn't getting store updates when I expected them.Turns out that shallow returns the wrong thing in a case like follows:
Seems like what happens is that it compares the length, which looks right. It then iterates the first object and looks for matching keys in the object. The problem is that here it resolves to undefined for both objects, but it never checks the key on the second object.
Reproduction Link
https://www.typescriptlang.org/play/?#code/PTAEDp2Tqg7A9gEwKYH0C2yCuAbFAzsAF7YEAuAhnEsIRsAG7UCWuulwBAFpewgHdwGAFYEAUMwBOoFgQCS5FFMoAjfKAC8oABQJVIgFyhqATwCUWgHygAyqYyqEucCyUryCGSzih9IgG5JShleBXc1fABROHIpFkItXWZcbBRjM0tNGx1xUFAQUAAJAEEAYQBpDMYEFiRQAGNuFAaAax8Ac1AUWPjE8lMABxQ80AAiHriEgjHZXxS08XMg6UaEDEGQlBipxO0dBZQSgBpQQ4AhLJsAb1GGhDgKUAxKQZKkw-efCmoGlAQAGagACyr1AAH4znw0u9jHAUAIQa8DtCjuBJn0CDpzMs7g8ni9BucPqjid8qHA-oCkYMIVDUihiXCETSUQzzujetNsbj8iwgTpCSVwAQWMQUKAAISabSEjmi8WWW75fJSFDkbBSXwAvgEFBBfIAX1GAK8unuj3IoAA2q0UKZTocALp+IFCpWjPkCyUAeQMLXIrixh1OcvAHXVOjtFhxoGVKtV6s12t1+s9oGNRtGao1WtAcTSQUNKxCaw2W0Uykie2SqJO9LSl2scbxltkEU8Une2k+1vsjmcrg7Xid2INazbbirneJPdJfYcThcU48I7Ho3wVvhAA9yN329OvMKd+R1-lN6AT7OD6upByT2fQAJuGwJTpJSfhUgHhKAGS-qUr3Ab94Q9BN+V0X1-QaQM5B0T9wBDS8UF3DlDljeMExzZNQB1XA9XHLME0-JIV0oTtjxQ09eRVK9SOHO9wAfGjM1AbC80lD8qK-H9QH-KUuNQ4CfyLIIAWwSlyBYB5QB4PhcEENkYUdUkwNkAU-REAMgyUo4VPZDD03Y3wCzTIj1N0AZhmpT4pRlcZ-ADWYAB9nIbI4tHsuA8FwUBXPzIZ-iBC47O0MZHJgly3JCmVtG89g1MTXMU3wsyM1GCD3zkSsVHUFBdJKSx-MlbKIjy3TLkStikzze5yzVHZMVyBN8mubouUIYxsWbTTtIxblPksQ1jnTVr2t2AguquUBepgzkJoqob0xYjKBTCHLq0aga60sfj1rK6IOuDVSquMstNgao6Cv0xsVqSnC6oulANry46GXrC5cWNcQLQIZwUHABSOh0OT+AEHQ2oAcgARkh4wJNQAEfBQephrjUBIYAJjhuNt2MaHDUNHEgA
Beta Was this translation helpful? Give feedback.
All reactions