• 
      

    Fix typing of defaults and each() for the JavaScript ExtensionHook.

    Review Request #14568 — Created Aug. 21, 2025 and submitted — Latest diff uploaded

    Information

    Djblets
    release-5.x

    Reviewers

    Djblets.ExtensionHook has two issues that make it difficult to build
    and use hook implementations.

    The first is that defaults was a hard-coded ExtensionHookAttrs,
    rather than a Partial<ExtensionHookAttrs>, which means that any
    subclass must also include everything in ExtensionHookAttrs in their
    defaults. This isn't necessary with Spina, which will merge the
    dictionaries together. By switching to Partial<...>, 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 as ExtensionHook and 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.

    Commits

    Files