Details
-
Improvement
-
Resolution: Fixed
-
Major
-
18.8.0
-
None
Description
The TypeScript modules that read the global XWiki object each declare it on their own, with diverging types:
- 7 modules (blocknote webjar, authentication-xwiki, autosave-xwiki, backend-xwiki, document-xwiki, model-reference-xwiki, model-remote-url-xwiki) copy the same declare global block pointing to XWikiGlobal from @xwiki/platform-xwiki-utils
- the Flamingo design system webjar and the localization webjar declare their own partial types
- livedata-xwiki declares it as any
- livedata-ui reads it through an untyped JavaScript shim and silences the type checker with @ts-expect-error to use XWiki.widgets
As a result, a member of the global can be typed differently, or not at all, depending on the module, and every new module has to copy the declaration again.
Proposal
- @xwiki/platform-xwiki-utils exposes a types-only ./global entry declaring const XWiki: XWikiGlobal, which modules opt into with /// <reference types="@xwiki/platform-xwiki-utils/global" />
- XWikiGlobal gains the widgets member (Notification, ConfirmationBox) contributed by the core skin scripts, typed only as far as it is used
- members contributed by extensions are added by the extension's own package through declaration merging on XWikiGlobal, so that they are only visible where the extension is loaded
- all the modules above use the shared declaration; the web webjar, which assigns the global before xwiki.js is loaded, keeps its own write-side declaration
Attachments
Issue Links
- relates to
-
XWIKI-24372 Implement auto-save for BlockNote realtime collaboration sessions
-
- Closed
-