Add typing and HTML element test improvements for JavaScript.

Review Request #14403 — Created April 24, 2025 and submitted

Information

Review Board
release-7.1.x

Reviewers

This updates our JavaScript codebase to fix some typing issues and to
make it easier to compare HTML elements in testing.

We now set a global reference to the babel-plugin-django-gettext
types, which provides a merged Underscore.js + Gettext type for _.
This allows us to use _.funcs() as normal while also properly
localizing strings using the _ prefix.

Modules may also now use declare to declare types . This is useful for
classes that want to type a definition on the prototype that will be set
elsewhere (such as via the @spina decorator).

Unit tests that compare elements will now see the HTML of both values in
any error messages. This is done by registering a custom object
formatter that works with HTMLElement and subclasses. This just uses
the outerHTML of each value.

Unit tests pass.

Made use of all of this in in-progress changes.

Summary ID
Add typing and HTML element test improvements for JavaScript.
This updates our JavaScript codebase to fix some typing issues and to make it easier to compare HTML elements in testing. We now set a global reference to the `babel-plugin-django-gettext` types, which provides a merged Underscore.js + Gettext type for `_`. This allows us to use `_.funcs()` as normal while also properly localizing strings using the `_` prefix. Modules may also now use `declare` to declare types . This is useful for classes that want to type a definition on the prototype that will be set elsewhere (such as via the `@spina` decorator). Unit tests that compare elements will now see the HTML of both values in any error messages. This is done by registering a custom object formatter that works with `HTMLElement` and subclasses. This just uses the `outerHTML` of each value.
6293938a1dc5f429f2f1bf525861f5227e670ea3
david
  1. Ship It!
  2. 
      
maubin
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-7.1.x (af413cf)