Skip to content

Types: Replace remaining @ts-expect-error suppressions with proper typing - #81200

Merged
manzoorwanijk merged 2 commits into
trunkfrom
fix/ts-expect-error-typing-followups
Aug 5, 2026
Merged

Types: Replace remaining @ts-expect-error suppressions with proper typing#81200
manzoorwanijk merged 2 commits into
trunkfrom
fix/ts-expect-error-typing-followups

Conversation

@manzoorwanijk

Copy link
Copy Markdown
Member

What?

Follow up to #81148

Removes five @ts-expect-error suppressions by typing the code properly instead of documenting why the suppression was needed.

Why?

Review feedback on #81148 flagged several of the backfilled descriptions as cases where the disabling comment was hiding a fix rather than a genuine type limitation.

How?

  • input-control: document.documentElement.style.removeProperty( 'cursor' ) instead of assigning null, which only worked through WebIDL's LegacyNullToEmptyString coercion.
  • Icon: pass the forwarded sizing props as the type argument to isValidElement, so cloneElement accepts size/width/height.
  • DataViews properties section: type isVisibleFlag as 'showTitle' | 'showMedia' | 'showDescription' so it can index View. Removes two suppressions.
  • Block supports: type the object form of spacing.blockGap ({ __experimentalDefault?, sides? }), which blocks like core/columns already use, and narrow at the call site in the global styles engine.
  • Global styles background: narrow backgroundImage to the member carrying a url with a type predicate.

Two comments from the review are intentionally not addressed here, as both need more than a local fix:

  • inert in dataviews-footer: React 18's types do not declare it and React 19's type it as boolean, so no single literal typechecks against both. The same suppression exists in @wordpress/boot, so this wants one shared answer.
  • label in dataviews-filters/filter.tsx: getOperatorByName returns a union, so typing the between operator's string[] label means threading a new element type through every operator definition.

Testing Instructions

No behaviour changes. CI type checks and unit tests cover this.

  1. npm run build:package-types passes.
  2. Confirm dragging a NumberControl/RangeControl label still shows the drag cursor and restores the default cursor on release.

Testing Instructions for Keyboard

N/A, no UI changes.

Use of AI Tools

The changes were drafted with Claude Code and reviewed by me.

Setting `style.cursor = null` relied on WebIDL's LegacyNullToEmptyString
coercion and needed a `@ts-expect-error`. `removeProperty( 'cursor' )`
does the same thing in a type-compliant way.
…-expect-errors

Follow-up to review feedback on #81148: type each of these sites so the
suppression is unnecessary rather than describing why it was needed.

- Icon: type the cloned element's props as the sizing props it forwards.
- Properties section: key `isVisibleFlag` to the `View` flags it indexes.
- Block supports: type the object form of `spacing.blockGap`.
- Background: narrow `backgroundImage` with a type predicate.
@github-actions github-actions Bot added [Package] Components /packages/components [Package] Blocks /packages/blocks [Package] DataViews /packages/dataviews labels Aug 5, 2026
@manzoorwanijk manzoorwanijk added the [Type] Code Quality Issues or PRs that relate to code quality label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Size Change: +97 B (0%)

Total Size: 7.81 MB

📦 View Changed
Filename Size Change
build/modules/lazy-editor/index.min.js 14.8 kB +29 B (+0.2%)
build/scripts/block-editor/index.min.js 433 kB +10 B (0%)
build/scripts/components/index.min.js 278 kB +8 B (0%)
build/scripts/edit-site/index.min.js 311 kB +17 B (+0.01%)
build/scripts/editor/index.min.js 509 kB +33 B (+0.01%)

compressed-size-action

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka 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.

Nice cleanup. Thank you, @manzoorwanijk!

@manzoorwanijk
manzoorwanijk merged commit f930616 into trunk Aug 5, 2026
76 of 78 checks passed
@manzoorwanijk
manzoorwanijk deleted the fix/ts-expect-error-typing-followups branch August 5, 2026 05:47
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 5, 2026
shail-mehta pushed a commit that referenced this pull request Aug 12, 2026
…typing (#81200)

* Components: Use removeProperty to clear the drag cursor

Setting `style.cursor = null` relied on WebIDL's LegacyNullToEmptyString
coercion and needed a `@ts-expect-error`. `removeProperty( 'cursor' )`
does the same thing in a type-compliant way.

* Types: Replace remaining input-control, icon, dataviews and styles ts-expect-errors

Follow-up to review feedback on #81148: type each of these sites so the
suppression is unnecessary rather than describing why it was needed.

- Icon: type the cloned element's props as the sizing props it forwards.
- Properties section: key `isVisibleFlag` to the `View` flags it indexes.
- Block supports: type the object form of `spacing.blockGap`.
- Background: narrow `backgroundImage` with a type predicate.

Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Blocks /packages/blocks [Package] Components /packages/components [Package] DataViews /packages/dataviews [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants