Fix typing of defaults and each() for the JavaScript ExtensionHook.
Review Request #14568 — Created Aug. 21, 2025 and submitted — Latest diff uploaded
Djblets.ExtensionHookhas two issues that make it difficult to build
and use hook implementations.The first is that
defaultswas a hard-codedExtensionHookAttrs,
rather than aPartial<ExtensionHookAttrs>, which means that any
subclass must also include everything inExtensionHookAttrsin their
defaults. This isn't necessary with Spina, which will merge the
dictionaries together. By switching toPartial<...>, subclasses can
type their own using their own attributes and rely on parent class
defaults.The second issue is that
ExtensionHook.each(), meant to iterate
through all instances of a hook for a given hook point, typed the hook
being passed to the callback asExtensionHookand not as the subclass.
This forced callers to re-type, which was annoying. Now, we use generics
to reflect the specific subclass.
Unit tests pass.
Tested this with in-progress code in Review Board, verifying that the
typing was correct.