feat: convert remaining JS assets to Typescript#153
feat: convert remaining JS assets to Typescript#153justlevine wants to merge 3 commits intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR continues the JS→TypeScript migration for admin search-related assets, updating build entrypoints and adding stronger typing + small UI/accessibility adjustments in several React components.
Changes:
- Switch the
searchwebpack entry fromindex.jstoindex.tsx. - Add TypeScript typings and URL-normalization helpers across search settings and indexable entities components.
- Refactor
MultiSelectChipsfor better keyboard interaction and typed event handling.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
webpack.config.js |
Updates admin search entrypoint to index.tsx. |
assets/src/admin/search/index.tsx |
Converts admin search settings page to TSX with typed state, fetch responses, and notice handling. |
assets/src/components/SiteSearchSettings.tsx |
Adds TS types, uses shared withTrailingSlash, and refines dirty-checking/auto-save typing. |
assets/src/components/SiteIndexableEntities.tsx |
Adds TS types for entity maps and API responses; refines error handling and UI keys. |
assets/src/components/MultiSelectChips.tsx |
Adds TS props/types and improves keyboard interactions / ARIA labeling for chip removal. |
.stylelint.config.js |
Expands ignore patterns to include JSX/TS/TSX (currently with malformed TS globs). |
Comments suppressed due to low confidence (8)
assets/src/admin/search/index.tsx:15
defaultBrandSiteis imported usingimport type, but this module later usestypeof defaultBrandSite(a type query) which requiresdefaultBrandSiteto be available in the value space. Withstrict+isolatedModules, this will fail to type-check. ImportdefaultBrandSiteas a normal value import (and keepBrandSite/NoticeTypeas type-only imports) or avoid thetypeoftype query here.
assets/src/admin/search/index.tsx:33BrandSiteFormData = typeof defaultBrandSitewill error as long asdefaultBrandSiteis a type-only import. Either switch to a value import fordefaultBrandSite, or replace this with an explicit interface/type (e.g.,BrandSite) so the file doesn’t depend on a value-level symbol for typing.
assets/src/components/MultiSelectChips.tsx:132- The trigger is now a
divwithrole="button", but it doesn’t setaria-disabledwhendisabledis true. Since there is no nativedisabledattribute on adiv, screen readers won’t reliably announce the disabled state. Addaria-disabled={disabled}on the element withrole="button"(and keep the existing tabIndex/click guards).
assets/src/components/SiteIndexableEntities.tsx:386 - Brand-site lookups use the raw
site.urlas the key (e.g.,allPostTypes?.[ site?.url ]), but other parts of the flow normalize URLs withwithTrailingSlashwhen building theallPostTypesmap. This mismatch can cause valid post types to appear missing for brand sites. Normalizesite.urlbefore indexing intoallPostTypeshere.
assets/src/components/SiteIndexableEntities.tsx:395 selectedEntitiesis keyed by site URL, but this block reads/writes using the rawsite?.urland passes it tohandleSelectedEntitiesChange. If the API keys are normalized (trailing slash) this will store selections under a different key and the UI will not reflect saved selections. Use the same normalized URL key (e.g.,withTrailingSlash(site.url)) consistently forvalue,onChange, and map access.
assets/src/components/SiteSearchSettings.tsx:549ToggleControlis given an emptylabel. This makes the control effectively unlabeled for assistive tech. Provide an accessible label (and optionally hide it visually withhideLabelFromVision) that describes what toggling does for the specific site.
assets/src/admin/search/index.tsx:94- This
useEffectusesfetchEntitiesfrom the component scope but has an empty dependency array. With the repo’s React hooks linting, this will be flagged as missing dependencies. WrapfetchEntitiesinuseCallbackand include it in the deps array (or inline the fetch logic inside the effect).
assets/src/components/MultiSelectChips.tsx:41 useRef< HTMLDivElement >( null )is not valid understrictNullChecksbecausenullisn’t assignable toHTMLDivElement. UseuseRef<HTMLDivElement | null>( null )(or a non-null assertion) so the ref type matches its initial null value.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
up1512001
left a comment
There was a problem hiding this comment.
@justlevine Did not tested locally but I would highly doubt that this will work same as previous...
| </span> | ||
| <span | ||
| role="button" | ||
| <button |
There was a problem hiding this comment.
why not use Button component instead??
https://wordpress.github.io/gutenberg/?path=/docs/design-system-components-button--docs
There was a problem hiding this comment.
Because changing a <span> to a <button> to fix a nesting violation is less intrusive then migrating an entire component.
|
|
||
| /** | ||
| * Internal dependencies | ||
| * External dependencies |
There was a problem hiding this comment.
types are from our internal file 😕
There was a problem hiding this comment.
@ makes them external to the current module. Fixed the labeling here: 48873cb
| [ siteUrl: string ]: string[]; | ||
| } | ||
|
|
||
| interface SiteIndexableEntitiesProps { |
There was a problem hiding this comment.
confirmed originalData props are not used so no need to pass it, why types check did not pickup this issue @justlevine may be you need to check?
There was a problem hiding this comment.
| <Button | ||
| variant="primary" | ||
| onClick={ handleReIndex } | ||
| onClick={ () => handleReIndex() } |
There was a problem hiding this comment.
what problem does this solves, as we are not passing any events to handleReIndex function, I don't think this change is required
Thanks for the feedback and I'll review shortly. Keep in mind the goal isn't to fix the logical issues with the current implementation, just to make them typesafe. |
3bd4d40 to
53fdb7b
Compare
|
@up1512001 I cleaned up based on your feedback (rebasing the diff helped too). Remaining open comments are for your approval |

Description
Migrates the remaining JS asset files to typescript
Important
This PR is based on #152 which should be merged first.
Technical Details
Prompted (oh-my-opencode + glm+5)
Audit these new tsx files for slop ulwManually reviewed the changes.
Checklist
Screenshots
To-do
Fixes/Covers issue
Fixes #