Repository navigation
chore(superset-ui-switchboard): forward-compat fixes for TypeScript 6.0 (Phase E) - #40028
Conversation
Code Review Agent Run #e403e4Actionable 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 |
2b22cac to
60db174
Compare
Code Review Agent Run #e7beb5Actionable 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 |
Phase E of the TS 5.4 → 6.0 migration tracked in #39539. Scoped to packages/superset-ui-switchboard. Compiles cleanly under both TS 5.4.5 (current CI pin) and TS 6.0.3, eliminating 5 TS 6.0 errors: - 3 × TS2564 (strict property initialization) in switchboard.ts — Switchboard class fields `port`, `debugMode`, `isInitialised` had no initializer and weren't assigned in the constructor (they're set later in `init()`). Added definite- assignment `!` to `port` (no sensible default; class is unusable pre-init) and initialized `debugMode`/`isInitialised` to `false`, which matches the runtime defaults already used in `init()`. - 2 × TS2322 (FakeMessagePort/MessagePort mismatch) in switchboard.test.ts — TS 6.0's stricter inference rejects assigning a FakeMessagePort to `MessagePort` because `addEventListener`'s overload set no longer accepts the simpler `(event: 'message', handler: EventHandler) => void` signature. The fake only implements the subset of MessagePort that Switchboard exercises, so we cast at the assignment with `as unknown as MessagePort` per the playbook (targeted boundary casts, no widening of the production type). `packages/generator-superset` was in scope but has zero TS 6.0 source errors, so it's left untouched. No runtime behavior changes. Switchboard's 13 jest tests still pass. Part of the TypeScript 5.4 → 6.0 migration, split per-package to keep reviews small. See #39539 for the full roadmap. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
60db174 to
0793a8e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40028 +/- ##
=======================================
Coverage 64.03% 64.03%
=======================================
Files 2590 2590
Lines 137949 137951 +2
Branches 32000 32000
=======================================
+ Hits 88331 88338 +7
+ Misses 48100 48095 -5
Partials 1518 1518
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:
|
Code Review Agent Run #a4cdccActionable 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 |
aminghadersohi
left a comment
There was a problem hiding this comment.
Amingor review (Amin's PR bot at Preset) — HEAD 0793a8e
LGTM. Clean, surgical TypeScript 6.0 forward-compat fixes across 2 files (+8/-5 lines). No behavioral changes.
Changes reviewed:
switchboard.ts:91—port!: MessagePortdefinite assignment assertion. Correct given the two-phase init design; allthis.portaccesses are gated byisInitialisedguards so the runtime invariant holds.switchboard.ts:100,102—debugMode = false/isInitialised = falsereplacing bare type declarations. Strictly better: eliminates implicitundefinedstate.switchboard.test.ts:98–102—as unknown as MessagePortcast at the fake/real boundary. Right pattern; the comment explaining why ("without weakening the production type") is exactly the kind of non-obvious remark that deserves to be there.
No new any types, no secrets, no behavioral changes, no security surface.
….0 (Phase E) (#40028) Co-authored-by: Claude <claude@anthropic.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Part of #39539 (TypeScript 5.4 → 6.0 migration tracking issue).
SUMMARY
Phase E of the per-package TypeScript 6.0 migration. Scoped to
packages/superset-ui-switchboard. Compiles cleanly on TypeScript 5.4.5 (current CI) and eliminates all TS 6.0 source errors in this package — specifically 3 ×TS2564(strict property initialization) and 2 ×TS2322(DOMMessagePortoverload tightening).Fixes:
src/switchboard.ts— theSwitchboardclass assignsport,debugMode, andisInitialisedinsideinit()rather than the constructor, so strict-init complains under TS 6.0:port!: MessagePort— definite-assignment; the class is unusable untilinit()is called and there's no sensible default for a transport handle.debugMode = false/private isInitialised = false— natural defaults that already match the runtime semantics ininit()(wheredebug = falseis the destructuring default andisInitialisedis checked-falsy at the top of the method).src/switchboard.test.ts— TS 6.0's stricter inference rejects assigning aFakeMessagePortto aMessagePortfield becauseaddEventListener's overload set no longer accepts a simplified(event: 'message', handler: EventHandler) => voidsignature. The fake only implements the subset ofMessagePortthatSwitchboardexercises; cast at the boundary withas unknown as MessagePortper the playbook (no production-type widening).packages/generator-supersetwas in scope per #39539 but measured zero TS 6.0 source errors, so it's left untouched.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — no user-visible changes.
TESTING INSTRUCTIONS
cd superset-frontend && npx tsc --build packages/superset-ui-switchboard— clean (TS 5.4.5).cd superset-frontend && npx -p typescript@6.0.3 tsc --noEmit -p packages/superset-ui-switchboard/tsconfig.json— clean onceignoreDeprecations: "6.0"is added to suppress the unrelatedTS5101baseUrl warning (deferred to the final config-cleanup PR).npx jest packages/superset-ui-switchboard— 13/13 tests pass.pre-commit run --files superset-frontend/packages/superset-ui-switchboard/src/switchboard.ts superset-frontend/packages/superset-ui-switchboard/src/switchboard.test.ts— all hooks green.ADDITIONAL INFORMATION
Migration roadmap (for reviewers):
packages/superset-ui-core, rebased and mergeable)packages/superset-core)packages/superset-ui-chart-controls(blocked on B)packages/superset-ui-switchboard(+generator-superset— clean, no changes needed)superset-frontend/src/(may split into F1/F2/…; blocked on B/C/D)baseUrlmigration +typescript@6.0.3pin🤖 Generated with Claude Code