Skip to content

chore: remove uncontroversial ts-expect-error suppressions#540

Merged
willeastcott merged 2 commits into
mainfrom
chore/remove-uncontroversial-ts-expect-errors
May 27, 2026
Merged

chore: remove uncontroversial ts-expect-error suppressions#540
willeastcott merged 2 commits into
mainfrom
chore/remove-uncontroversial-ts-expect-errors

Conversation

@willeastcott
Copy link
Copy Markdown
Contributor

Summary

Three pure typing fixes that let us drop 12 of the existing // @ts-expect-error markers in pcui (38 → 26), with no runtime change and no public-API expansion.

  • Widen attachElement in the React wrapper base (src/components/Element/component.tsx) to (HTMLElement | SVGElement | null, any?) so it matches React's callback ref contract. The body already short-circuits on null, and the wider DOM type covers Spinner's <svg>. Matched in the LabelGroup override. Drops the suppression above every <… ref={this.attachElement} /> in Button, Canvas, ColorPicker, Container, Element, GradientPicker, InfoBox, Label, Spinner (9 sites).
  • Match ColorPicker.set values to the IBindable contract (src/components/ColorPicker/index.ts) — the parameter was declared Array<number> but the body already handles array-of-arrays (the Array.isArray(value) branch). Changed to Array<any> to match the interface (2 sites).
  • Annotate comboItems as Record<number, string> in src/components/GradientPicker/index.ts so the dynamic comboItems[3] = 'Legacy' assignment type-checks (1 site).

The remaining 26 suppressions all require a real API decision (visibility widening, dynamic-property data smell, or interface mismatches) and are intentionally left out of this PR.

Test plan

  • npm run build:types — tsc clean on both tsconfig.json and react/tsconfig.json (the removed markers were each suppressing an actual error before; tsc would fail if any deleted one weren't needed)
  • npm run lint:js — clean
  • npm run build:es6 — Rollup build green
  • npm test — 50/50 pass

🤖 Generated with Claude Code

willeastcott and others added 2 commits May 27, 2026 20:57
Three pure typing fixes that let us drop 12 of the existing `@ts-expect-error`
markers without any runtime change:

- Widen `attachElement` in the React wrapper base to
  `(HTMLElement | SVGElement | null, any?)` so it matches React's callback
  ref contract (allows null on unmount, and SVG for the Spinner wrapper).
  Matched in the LabelGroup override.
- Change `ColorPicker.set values` parameter from `Array<number>` to
  `Array<any>` to match the `IBindable` interface contract — the body
  already handles array-of-arrays.
- Annotate the `comboItems` literal in `GradientPicker` as
  `Record<number, string>` so the dynamic `comboItems[3] = 'Legacy'`
  assignment type-checks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@willeastcott willeastcott self-assigned this May 27, 2026
@willeastcott willeastcott requested a review from Copilot May 27, 2026 20:03
@willeastcott willeastcott added the enhancement New feature or request label May 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes several TypeScript suppression comments by aligning React wrapper ref typing and a couple of component typings with existing usage and interfaces.

Changes:

  • Widens React wrapper attachElement signatures to support callback refs, null, and SVG elements.
  • Removes now-unneeded @ts-expect-error comments from wrapper render refs.
  • Adjusts ColorPicker.values typing and GradientPicker combo item typing.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/components/Element/component.tsx Widens base attachElement callback ref type and removes base render suppression.
src/components/LabelGroup/component.tsx Mirrors the widened attachElement override signature.
src/components/Button/component.tsx Removes ref suppression.
src/components/Canvas/component.tsx Removes ref suppression.
src/components/ColorPicker/component.tsx Removes ref suppression.
src/components/ColorPicker/index.ts Aligns values setter with IBindable array contract.
src/components/Container/component.tsx Removes ref suppression.
src/components/GradientPicker/component.tsx Removes ref suppression.
src/components/GradientPicker/index.ts Adds a numeric record type for curve type combo items.
src/components/InfoBox/component.tsx Removes ref suppression.
src/components/Label/component.tsx Removes ref suppression.
src/components/Spinner/component.tsx Removes SVG ref suppression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/GradientPicker/index.ts
@willeastcott willeastcott merged commit 661884e into main May 27, 2026
6 checks passed
@willeastcott willeastcott deleted the chore/remove-uncontroversial-ts-expect-errors branch May 27, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants