chore(superset-ui-core): forward-compat fixes for TypeScript 6.0 (Phase B)#39535
chore(superset-ui-core): forward-compat fixes for TypeScript 6.0 (Phase B)#39535
Conversation
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>
Code Review Agent Run #e1dd2cActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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-coreonly. 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:
forwardRefcallbacks useForwardedRef<T>instead ofRefObject<T>(AsyncEsmComponent,DropdownContainer,ModalTrigger). TS 6.0 narrowsRefObject's contract, soforwardRef's callback parameter no longer assigns to it.ForwardedRef<T>is the correct type and accepts both object refs and callback refs.ModalTriggeradditionally adds atypeof ref !== 'function'guard before mutatingref.current.StatefulChart: castonRenderFailureto the sharedHandlerFunctiontype so the stricter 6.0 inference matches theSuperChartprop shape.AntdEnhanced: drop the widerIconType.componentfrom the spread so{...rest}can no longer override the explicit<BaseIconComponent component={...}>binding. This surfaced under 6.0's stricter JSX attribute checking becauseIconType.componentisForwardRefExoticComponent<CustomIconComponentProps>(wider thanBaseIconProps['component']), and the spread was silently overwriting the explicit attribute.Select/AsyncSelect: targetedas unknown as ...casts for sorter / filter / deselect / select call sites against antd'sBaseOptionType | DefaultOptionTypeandSelectHandlershapes. Our handlers read properties that always exist on the narrowerAntdLabeledValue, so the wider antd shape is safe at runtime.VirtualTable: acceptwidth?: numberfromreact-resize-detector's 6.0 callback signature, defaulting missing width to0.TableCollection: castcolumns/rowClassName/onChangeto antd's genericColumnsType<object>andTableProps<object>variants at the JSX boundary.TimezoneSelector: cast our comparator to antd'sLabeledValue-based sorter signature; our comparator only readstimezoneName, which always exists onTimezoneOption.connection/types: widenFetchRetryOptions'retryDelay/retryOnto acceptError | null/Response | null, matching thefetch-retrylibrary.fetchTimeRange: rename the catch variable and narrow viaParameters<typeof getClientErrorObject>[0]+ an inline{ statusText?: string }cast, since TS 6.0 defaults caught values tounknown.lruCache: guard theMapiterator's.valuebeforeMap#delete, because TS 6.0 typesIteratorResult.valueasstring | undefineduntil it's narrowed.InteractiveTableUtils: initialisecolumnReftonullforstrictPropertyInitialization.types/assets.d.ts: adddeclare 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).npm install typescript@6.0.3 --no-save) then runnpx 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.AntdEnhanced, andStatefulChart.ADDITIONAL INFORMATION
🤖 Generated with Claude Code