Add safer checks in ExtraDataMixin's logic to check extraData support.
Review Request #14407 — Created April 28, 2025 and submitted
ExtraDataMixin
has a series of checks to determine if it should
setthis.extraData
. When callingset()
, it makes a determination
based on the attributes passed in and the current object. This doesn't
always do the right thing, though.If attributes are passed in and
this.extraData
is not set, then we
fail when trying to call a method on it.Along with that, the method used to check
this.extraData
was a
presence check in the property, which isn't as safe as a truthiness
check. While fine in practice, this issue was encountered when changing
Babel's TypeScript options to enableallowDeclaredFields
, which
resulted inextraData
being explicitly set toundefined
.The safer check and the asserts should help catch any confusing issues
in the future.
Unit tests pass.
Tested with the failure condition and saw the more useful error.
Summary | ID |
---|---|
158626d1242bd138976d6d69fd9bb12b89e5d7d7 |
Description | From | Last Updated |
---|---|---|
Can you use a dedent string here instead of string concatenation? |
|