chore: Migrate JS to Typescript for few scripts - Phase 1#112
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the Phase 1 media-sharing admin UI and related frontend utilities from JS to TypeScript/TSX, and introduces shared frontend type definitions to centralize and standardize cross-script typings.
Changes:
- Switched the media-sharing webpack entrypoint to
index.tsxand migrated the media-sharing UI/components to TS/TSX. - Added shared type modules under
assets/src/types(settings, WordPress/media-frame typings, media-sharing domain types, globalwindowdeclarations). - Updated existing components/utilities to consume the new shared types (e.g., notices, site config types, MIME map typing).
Reviewed changes
Copilot reviewed 19 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| webpack.config.js | Updates media-sharing entrypoint to TSX. |
| assets/src/types/common.ts | Adds shared notice type used across UI/components. |
| assets/src/types/globals.d.ts | Centralizes window.* globals typing and SVG module typing. |
| assets/src/types/media-sharing.ts | Adds shared media-sharing domain/API/UI prop types. |
| assets/src/types/settings.ts | Adds shared settings/site config types and constants. |
| assets/src/types/wordpress.ts | Adds shared typings for WP media frame APIs used by uploader/modals. |
| assets/src/js/utils.ts | Refactors utility typings to use the new shared type modules. |
| assets/src/components/api.ts | Replaces api.js with a typed API client module. |
| assets/src/components/api.js | Removes the old JS API module (replaced by TS). |
| assets/src/components/SiteModal.tsx | Switches props typing to shared BrandSite types. |
| assets/src/components/SiteSettings.tsx | Switches notice typing to shared NoticeState. |
| assets/src/components/SiteTable.tsx | Switches site/editing typings to shared settings types. |
| assets/src/admin/settings/index.tsx | Removes inline window typings (now in global d.ts). |
| assets/src/admin/settings/page.tsx | Moves duplicated types to shared modules and adjusts notice rendering for ReactNode. |
| assets/src/admin/onboarding/index.tsx | Removes inline window typings (now in global d.ts). |
| assets/src/admin/onboarding/page.tsx | Uses shared site type constants/types and shared notice type. |
| assets/src/admin/media-sharing/index.tsx | Migrates main media-sharing UI to TSX with centralized types and updated asset loading. |
| assets/src/admin/media-sharing/components/ShareMediaModal.tsx | Migrates modal to TSX and introduces stronger prop typing. |
| assets/src/admin/media-sharing/components/VersionModal.tsx | Migrates modal to TSX and tightens event/version typing. |
| assets/src/admin/media-sharing/components/browser-uploader.tsx | Migrates uploader to TSX with shared WP/media-sharing typings. |
| assets/src/admin/media-sharing/components/syncIcon.tsx | Adds TSX icon module. |
| assets/src/admin/media-sharing/components/versionIcon.tsx | TSX formatting update to icon module. |
Comments suppressed due to low confidence (5)
assets/src/admin/media-sharing/components/ShareMediaModal.tsx:45
- Calling
setNotice(...)directly during render will trigger a state update on every render (new object each time), which can cause an infinite re-render loop / "Too many re-renders" error. Move this into auseEffect(run once whenbrandSitesPresentbecomes false) or render an inline notice within the modal instead of setting parent state from render.
assets/src/admin/media-sharing/components/ShareMediaModal.tsx:150 CheckboxControlis rendered with an emptylabel, so the checkbox has no accessible name for screen readers. Provide a meaningfullabel(can be visually hidden) or an explicitaria-label/aria-labelledbyso each site checkbox is identifiable.
assets/src/admin/media-sharing/index.tsx:546- This media selection checkbox has
label="", which leaves it without an accessible name. Provide an appropriate label (e.g., "Select <title>") oraria-label/aria-labelledbyso keyboard/screen reader users can understand what the checkbox selects.
assets/src/admin/media-sharing/components/VersionModal.tsx:147 - The version selection
CheckboxControlis rendered with an emptylabel, which means it has no accessible name. Provide a label oraria-label/aria-labelledbythat identifies which version will be selected/restored.
assets/src/admin/media-sharing/index.tsx:75 UPLOAD_NONCEreadswindow.OneMediaMediaSharing.uploadNoncebefore the laterONEMEDIA_MEDIA_SHARINGexistence checks. If the script is ever loaded without localization, this will throw immediately andlocalizationError()becomes unreachable. Use optional chaining/defaults when reading fromwindow.OneMediaMediaSharing(or compute this after verifying it exists).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
justlevine
reviewed
May 12, 2026
Collaborator
There was a problem hiding this comment.
Let's uses kebab-case.ts(x) for our files please
justlevine
reviewed
May 12, 2026
Collaborator
There was a problem hiding this comment.
From the contents, this seems like it should be renamed to types/notice.ts
justlevine
reviewed
May 12, 2026
justlevine
reviewed
May 12, 2026
justlevine
reviewed
May 12, 2026
justlevine
reviewed
May 12, 2026
justlevine
reviewed
May 12, 2026
justlevine
reviewed
May 12, 2026
justlevine
reviewed
May 12, 2026
justlevine
reviewed
May 12, 2026
justlevine
reviewed
May 12, 2026
justlevine
reviewed
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Migrates the Phase 1 media-sharing frontend JS files to TypeScript and adds shared frontend types.
Migrated files:
assets/src/components/api.js->assets/src/components/api.tsassets/src/admin/media-sharing/index.js->assets/src/admin/media-sharing/index.tsxassets/src/admin/media-sharing/components/ShareMediaModal.js->assets/src/admin/media-sharing/components/ShareMediaModal.tsxassets/src/admin/media-sharing/components/VersionModal.js->assets/src/admin/media-sharing/components/VersionModal.tsxassets/src/admin/media-sharing/components/browser-uploader.js->assets/src/admin/media-sharing/components/browser-uploader.tsxassets/src/admin/media-sharing/components/syncIcon.js->assets/src/admin/media-sharing/components/syncIcon.tsxassets/src/admin/media-sharing/components/versionIcon.js->assets/src/admin/media-sharing/components/versionIcon.tsxWhy
Moves the media-sharing admin UI onto the existing TypeScript setup and centralizes shared frontend types.
How
assets/src/typesTesting Instructions
npm run lint:js:types -- --pretty falsenpm run test:jsScreenshots
Additional Info
Checklist
npm run changeset.