rusackas opened a new pull request, #44186: URL: https://github.com/apache/superset/pull/44186
### SUMMARY First step in cleaning up the `any` types that leak out of `src/components/ListView/utils.ts` into every consumer that calls `useListViewState` (roughly 21 CRUD list pages across the app inherit it). `@types/react-table` deliberately ships `TableOptions`/`TableInstance`/`TableState` as near-empty base interfaces — the documented pattern is for each project to extend them via declaration merging with exactly the plugin hooks it uses (see the doc comment in `@types/react-table`'s own `index.d.ts`, linking https://gist.github.com/ggascoigne/646e14c9d54258e40588a13aabf0102d). Superset never set this up, so `useTable(...)` in `ListView/utils.ts` was fully cast through `as any` for its options, initial state, and returned instance. This adds `src/types/react-table.d.ts`, augmenting those three interfaces with the five plugin hooks `ListView` actually uses (`useFilters`, `useSortBy`, `usePagination`, `useRowState`, `useRowSelect`), then genericizes `useListViewState<D>` and drops every `as any` in the file. Also removed two small pieces of dead code found along the way: `removeFromList` and `extractInputValue` were both exported but had zero call sites anywhere in the codebase, and the `...({ count } as any)` spread into `useTable`'s options was a no-op (`count` isn't a recognized option on any react-table plugin, and `pageCount` — the thing actually derived from it — is already computed on the line above). `CardCollection` and `TableCollection` needed matching generic plumbing to keep `ListView.tsx` compiling now that the hook's return values are properly typed instead of erased to `any` end-to-end. `TableCollection` also needed a small `as typeof TableCollection` cast after `memo()`, since `React.memo` erases a wrapped component's generic type parameter by default. `ListView.tsx` itself and its ~21 consumer pages still have plenty of `any` left — this PR is scoped to the shared hook file only, as a first step. ### TESTING INSTRUCTIONS - `npx tsc -b .` — clean (the handful of remaining errors on a full `--force` rebuild are pre-existing declaration-emit quirks in unrelated files: `d3`/`echarts` types and a couple of `.stories.tsx` files, none of which this PR touches) - `npx jest src/components/ListView/ListView.test.tsx src/pages/DatasetList/DatasetList.listview.test.tsx src/pages/ChartList/ChartList.listview.test.tsx src/pages/DashboardList/DashboardList.listview.test.tsx packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx` — 5 suites, 116 tests, all passing - `pre-commit run` on the changed files — clean ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] 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 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
