Add typing and HTML element test improvements for JavaScript.
Review Request #14403 — Created April 24, 2025 and submitted — Latest diff uploaded
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 withHTMLElement
and subclasses. This just uses
theouterHTML
of each value.
Unit tests pass.
Made use of all of this in in-progress changes.
reviewboard/packaging/js/babel.base.config.json |
---|
reviewboard/static/rb/js/global.d.ts |
---|
reviewboard/templates/js/tests_base.html |
---|