Skip to content

[ZEPPELIN-6447] Add Module Federation typing for the published paragr…#5343

Open
JangAyeon wants to merge 1 commit into
apache:masterfrom
JangAyeon:ZEPPELIN-6447
Open

[ZEPPELIN-6447] Add Module Federation typing for the published paragr…#5343
JangAyeon wants to merge 1 commit into
apache:masterfrom
JangAyeon:ZEPPELIN-6447

Conversation

@JangAyeon

@JangAyeon JangAyeon commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

What is this PR for?

PublishedParagraphComponent.loadReactWidget() read the global Module Federation container via window.reactApp behind a @ts-ignore comment, so the compiler couldn't check the container.get(...) call that follows it.

ReactRemoteLoaderService already declares this container's shape as RemoteContainer and augments Window.reactApp with it globally. This PR exports that existing interface and reuses it here instead of adding a second, possibly conflicting Window.reactApp typing.

What type of PR is it?

Improvement

Todos

  • Remove the @ts-ignore comment near window.reactApp
  • Type the container with the existing RemoteContainer interface (covers the get API used here)
  • Preserve the window.reactApp not available error when the container is missing

What is the Jira issue?

ZEPPELIN-6447

How should this be tested?

  • cd zeppelin-web-angular && npm run lint passes with no new errors.
  • Load a published paragraph with ?react=true and confirm the React widget still mounts; without the remote entry script, the "window.reactApp not available" error still surfaces.

Questions:

  • Does the license files need to update? No
  • Is there breaking changes for older versions? No
  • Does this needs documentation? No

…aph React container

Reuses the RemoteContainer type already declared by ReactRemoteLoaderService (ZEPPELIN-6428) for window.reactApp, removing the @ts-ignore in PublishedParagraphComponent.loadReactWidget() so the container's get() call is type-checked instead of suppressed.

@voidmatcha voidmatcha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsc passes locally, so removing the @ts-ignore works.

One thing that isn't obvious from the issue: the type declaration ZEPPELIN-6447 asks for already exists. 52a638e (ZEPPELIN-6428, Jun 17) added a declare global block at react-remote-loader.service.ts:22 declaring Window.reactApp as RemoteContainer | undefined, and it applies program-wide. The issue was filed on Jun 27, so criterion 2 ("the container type includes at least the get API") was already satisfied by the time it was written, and the @ts-ignore was the only part left.

Which means the import and the export don't add any typing. I reverted the import, the annotation and the export and ran tsc again, and the output was the same (exit 0, nothing printed). To rule out the type having fallen back to any I added container?.nope() with no import, and it still errored with TS2339: Property 'nope' does not exist on type 'RemoteContainer'.

f5ab35f

Either way works, just flagging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants