Add safer checks in ExtraDataMixin's logic to check extraData support.

Review Request #14407 — Created April 28, 2025 and submitted

Information

Review Board
release-7.1.x

Reviewers

ExtraDataMixin has a series of checks to determine if it should
set this.extraData. When calling set(), 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 enable allowDeclaredFields, which
resulted in extraData being explicitly set to undefined.

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
Add safer checks in ExtraDataMixin's logic to check extraData support.
`ExtraDataMixin` has a series of checks to determine if it should set `this.extraData`. When calling `set()`, 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 enable `allowDeclaredFields`, which resulted in `extraData` being explicitly set to `undefined`. The safer check and the asserts should help catch any confusing issues in the future.
158626d1242bd138976d6d69fd9bb12b89e5d7d7
Description From Last Updated

Can you use a dedent string here instead of string concatenation?

daviddavid
david
  1. 
      
  2. Show all issues

    Can you use a dedent string here instead of string concatenation?

    1. Unfortunately no, because that'll preserve the newline.

  3. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-7.1.x (b99d05c)