Refactor away from is.plainObject
#22666
Labels
priority-3-medium
Default priority, "should be done" but isn't prioritised ahead of others
type:refactor
Refactoring or improving of existing code
Describe the proposed change(s).
We currently use the
@sindresorhus/is
library to simplify a lot of type checking throughout Renovate. During a refactor from our ownclone
function tostructuredClone
in #20885 we saw some issues with some of the limitations ofstructuredClone
. Namely, the prototype chain is not preserved.After the PR was merged another issue emerged, #22058. The root cause of this is the implementation of
is.plainObject
is not compatible with use ofstructuredClone
:The prototype of the object being checked is compared with the prototype of the
Object
type. This will always returnfalse
with objects that are cloned withstructuredClone
.I don't believe this is a bug with
@sindresorhus/is
, as it's explicitly called out in their documentation:Therefore, if we want to continue using
structuredClone
(we do! See #20553) we need to migrate away fromis.plainObject
to something else.The naive choice is
is.object
. However, the implementation is not exactly whatAnd the documentation confirms this:
That only really leaves
is.nonEmptyObject
(and its counterpartis.emptyObject
). Its implementation is:I think this is currently the best path forward, though I've also opened sindresorhus/is#183 to get feedback from upstream
Describe why we need/want these change(s).
is.plainObject
is incompatible withstructuredClone
The text was updated successfully, but these errors were encountered: