Skip to content

chore(superset-ui-core): forward-compat fixes for TypeScript 6.0 (Phase B)#39535

Open
rusackas wants to merge 1 commit intomasterfrom
ts6-migration/phase-b-superset-ui-core
Open

chore(superset-ui-core): forward-compat fixes for TypeScript 6.0 (Phase B)#39535
rusackas wants to merge 1 commit intomasterfrom
ts6-migration/phase-b-superset-ui-core

Conversation

@rusackas
Copy link
Copy Markdown
Member

@rusackas rusackas commented Apr 22, 2026

Part of #39539 (TypeScript 5.4 → 6.0 migration tracking issue).

SUMMARY

Part of the TypeScript 5.4.5 → 6.0 migration, split per-package so reviews stay small. This PR is scoped to packages/superset-ui-core only. All changes compile cleanly on TypeScript 5.4.5 (current CI) and eliminate the TS 6.0 errors in that package, so future upgrade PRs will have strictly fewer errors to resolve.

No runtime behaviour changes. Every fix is either a signature widening, a type-only cast at a boundary where our code is known-safe, or a stricter internal type.

What changed, and why:

  • forwardRef callbacks use ForwardedRef<T> instead of RefObject<T> (AsyncEsmComponent, DropdownContainer, ModalTrigger). TS 6.0 narrows RefObject's contract, so forwardRef's callback parameter no longer assigns to it. ForwardedRef<T> is the correct type and accepts both object refs and callback refs. ModalTrigger additionally adds a typeof ref !== 'function' guard before mutating ref.current.
  • StatefulChart: cast onRenderFailure to the shared HandlerFunction type so the stricter 6.0 inference matches the SuperChart prop shape.
  • AntdEnhanced: drop the wider IconType.component from the spread so {...rest} can no longer override the explicit <BaseIconComponent component={...}> binding. This surfaced under 6.0's stricter JSX attribute checking because IconType.component is ForwardRefExoticComponent<CustomIconComponentProps> (wider than BaseIconProps['component']), and the spread was silently overwriting the explicit attribute.
  • Select / AsyncSelect: targeted as unknown as ... casts for sorter / filter / deselect / select call sites against antd's BaseOptionType | DefaultOptionType and SelectHandler shapes. Our handlers read properties that always exist on the narrower AntdLabeledValue, so the wider antd shape is safe at runtime.
  • VirtualTable: accept width?: number from react-resize-detector's 6.0 callback signature, defaulting missing width to 0.
  • TableCollection: cast columns / rowClassName / onChange to antd's generic ColumnsType<object> and TableProps<object> variants at the JSX boundary.
  • TimezoneSelector: cast our comparator to antd's LabeledValue-based sorter signature; our comparator only reads timezoneName, which always exists on TimezoneOption.
  • connection/types: widen FetchRetryOptions' retryDelay / retryOn to accept Error | null / Response | null, matching the fetch-retry library.
  • fetchTimeRange: rename the catch variable and narrow via Parameters<typeof getClientErrorObject>[0] + an inline { statusText?: string } cast, since TS 6.0 defaults caught values to unknown.
  • lruCache: guard the Map iterator's .value before Map#delete, because TS 6.0 types IteratorResult.value as string | undefined until it's narrowed.
  • InteractiveTableUtils: initialise columnRef to null for strictPropertyInitialization.
  • types/assets.d.ts: add declare module '*.css' for side-effect CSS imports.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — type-level changes only.

TESTING INSTRUCTIONS

  • cd superset-frontend && npm run type — should pass on TS 5.4.5 (current CI).
  • Optional forward-compat check: install TypeScript 6.0.3 locally (npm install typescript@6.0.3 --no-save) then run npx tsc --project packages/superset-ui-core/tsconfig.json --noEmit. Before this PR that reports 24+ errors in superset-ui-core; after this PR it reports 0.
  • Visually smoke-test the touched components in Explore / Dashboard / SQL Lab: Select / AsyncSelect (filter, deselect, sort), TimezoneSelector (report schedules), TableCollection, VirtualTable, ModalTrigger, any icon from AntdEnhanced, and StatefulChart.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

Scoped to packages/superset-ui-core. All changes compile cleanly on
TypeScript 5.4.5 (current CI) and eliminate TS 6.0 errors in this package.

Key fixes:

- forwardRef callbacks use ForwardedRef<T> instead of RefObject<T>
  (AsyncEsmComponent, DropdownContainer, ModalTrigger). ModalTrigger
  also narrows object-ref access with a typeof-function guard.
- StatefulChart: cast onRenderFailure to the shared HandlerFunction type
  so the stricter 6.0 inference matches the SuperChart prop.
- AntdEnhanced: drop the wider IconType.component from the spread so
  {...rest} can no longer override the explicit <BaseIconComponent
  component={...}> binding under 6.0's stricter JSX attribute checking.
- Select / AsyncSelect: widen antd sorter/filter/handler call-sites with
  targeted `as unknown as ...` casts against antd's BaseOptionType /
  DefaultOptionType / SelectHandler shapes. Behaviour unchanged; only
  the type boundary moves.
- VirtualTable: accept width?: number from react-resize-detector's 6.0
  callback signature, defaulting missing width to 0.
- TableCollection: cast columns / rowClassName / onChange to antd's
  generic ColumnsType<object> and TableProps<object> variants.
- TimezoneSelector: cast our comparator to antd's LabeledValue-based
  sorter signature; our comparator only reads fields that always exist
  on TimezoneOption, so the broader shape is safe at runtime.
- connection/types: widen FetchRetryOptions retryDelay/retryOn to
  accept `Error | null` / `Response | null`, matching fetch-retry.
- fetchTimeRange: rename catch variable and narrow it via the
  getClientErrorObject parameter type, handling TS 6.0's `unknown`
  default for caught values.
- lruCache: guard Map iterator .value before Map#delete (TS 6.0 types
  IteratorResult.value as `string | undefined`).
- InteractiveTableUtils: initialise columnRef to null for strict
  property initialization.
- types/assets.d.ts: add `declare module '*.css'` for CSS side-effect
  imports under 6.0's stricter module resolution.

Part of the TypeScript 5.4 -> 6.0 migration, split per-package to keep
reviews small. No runtime behaviour changes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Apr 22, 2026

Code Review Agent Run #e1dd2c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 15 · Commit Range: 9b5d89b..9b5d89b
    • superset-frontend/packages/superset-ui-core/src/chart/components/StatefulChart.tsx
    • superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/index.tsx
    • superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/DropdownContainer.tsx
    • superset-frontend/packages/superset-ui-core/src/components/Icons/AntdEnhanced.tsx
    • superset-frontend/packages/superset-ui-core/src/components/ModalTrigger/index.tsx
    • superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx
    • superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
    • superset-frontend/packages/superset-ui-core/src/components/Table/VirtualTable.tsx
    • superset-frontend/packages/superset-ui-core/src/components/Table/utils/InteractiveTableUtils.ts
    • superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx
    • superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/index.tsx
    • superset-frontend/packages/superset-ui-core/src/connection/types.ts
    • superset-frontend/packages/superset-ui-core/src/time-comparison/fetchTimeRange.ts
    • superset-frontend/packages/superset-ui-core/src/utils/lruCache.ts
    • superset-frontend/packages/superset-ui-core/types/assets.d.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 22, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 9b5d89b
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69e82ee59bf1520008bc30b3
😎 Deploy Preview https://deploy-preview-39535--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.54%. Comparing base (05fc5bb) to head (9b5d89b).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...rset-ui-core/src/components/Select/AsyncSelect.tsx 80.00% 1 Missing ⚠️
...rset-ui-core/src/components/Table/VirtualTable.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #39535   +/-   ##
=======================================
  Coverage   64.54%   64.54%           
=======================================
  Files        2559     2559           
  Lines      133496   133505    +9     
  Branches    31028    31035    +7     
=======================================
+ Hits        86168    86176    +8     
- Misses      45836    45837    +1     
  Partials     1492     1492           
Flag Coverage Δ
javascript 66.52% <90.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas rusackas changed the title chore(superset-ui-core): forward-compat fixes for TypeScript 6.0 chore(superset-ui-core): forward-compat fixes for TypeScript 6.0 (Phase B) Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant