rusackas opened a new pull request, #44877:
URL: https://github.com/apache/superset/pull/44877

   ### SUMMARY
   
   Phase D of the TypeScript 5.4 → 6.0 migration tracked in #39539. Scoped to 
`packages/superset-ui-chart-controls`, same forward-compat approach as Phase B 
(#39535), Phase C (#39537), and Phase E (#40028): compiles under both the 
current TS 5.4.5 pin and TS 6.0.3, no runtime behavior change.
   
   **Fix.** `getColorFunction` in `getColorFormatters.ts` declares 
`comparatorFunction` with a wide parameter type (`number | string | boolean | 
null`), then each `switch (operator)` branch assigns it a narrower function 
matching that operator's actual column type (e.g. `(value: number, allValues: 
number[]) => ...` for `GreaterThan`). TS 6.0 checks this assignment 
contravariantly and rejects every branch (`TS2322`); TS 5.4.5 accepted it. Each 
branch is only ever invoked below with a `value`/`allValues` pair matching its 
own operator — callers pick the operator based on the column's real type — so 
the fix casts each branch to the declared `ComparatorFunction` type, the same 
"handler boundary" pattern Phase B used for antd's sorter/filter/select 
callbacks.
   
   Measured 19 TS 6.0 errors (all `TS2322`, all in this one file) → 0, with no 
other errors remaining in the package. This was down from the issue's 
pre-Phase-B estimate of ~42 errors across TS7006/TS2322/TS2538 — Phase B 
landing narrowed `@superset-ui/core`'s exported types enough to clear most of 
them before this PR even started, as the tracking issue predicted.
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   cd superset-frontend
   
   # TS 6.0 check (should be clean)
   npm install [email protected] --no-save
   NODE_OPTIONS="--max-old-space-size=8192" npx tsc \
     --project packages/superset-ui-chart-controls/tsconfig.json \
     --noEmit --ignoreDeprecations 6.0
   
   # restore the pin and confirm no regression there either
   npm install [email protected] --no-save
   npx tsc --project packages/superset-ui-chart-controls/tsconfig.json --noEmit
   
   # existing tests, unmodified, all pass
   npx jest packages/superset-ui-chart-controls
   ```
   
   453 existing tests in the package pass unmodified (92 in 
`getColorFormatters.test.ts` specifically), confirming no behavior change. 
`pre-commit run` clean on the touched file.
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: #39539 (Phase D)
   - [ ] 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
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to