Skip to content

chore(superset-ui-switchboard): forward-compat fixes for TypeScript 6.0 (Phase E) - #40028

Merged
rusackas merged 1 commit into
masterfrom
ts6-migration/phase-e-small-leaves
May 20, 2026
Merged

rusackas merged 1 commit into
masterfrom
ts6-migration/phase-e-small-leaves

Conversation

@rusackas

Copy link
Copy Markdown
Member

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 (DOM MessagePort overload tightening).

Fixes:

  • src/switchboard.ts — the Switchboard class assigns port, debugMode, and isInitialised inside init() rather than the constructor, so strict-init complains under TS 6.0:

    • port!: MessagePort — definite-assignment; the class is unusable until init() 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 in init() (where debug = false is the destructuring default and isInitialised is checked-falsy at the top of the method).
  • src/switchboard.test.ts — TS 6.0's stricter inference rejects assigning a FakeMessagePort to a MessagePort field because addEventListener's overload set no longer accepts a simplified (event: 'message', handler: EventHandler) => void signature. The fake only implements the subset of MessagePort that Switchboard exercises; cast at the boundary with as unknown as MessagePort per the playbook (no production-type widening).

packages/generator-superset was 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 once ignoreDeprecations: "6.0" is added to suppress the unrelated TS5101 baseUrl 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):

🤖 Generated with Claude Code

@bito-code-review

bito-code-review Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e403e4

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 2b22cac..2b22cac
    • superset-frontend/packages/superset-ui-switchboard/src/switchboard.test.ts
    • superset-frontend/packages/superset-ui-switchboard/src/switchboard.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

@dosubot dosubot Bot added the packages label May 11, 2026
@rusackas
rusackas force-pushed the ts6-migration/phase-e-small-leaves branch from 2b22cac to 60db174 Compare May 11, 2026 19:42
@bito-code-review

bito-code-review Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e7beb5

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 60db174..60db174
    • superset-frontend/packages/superset-ui-switchboard/src/switchboard.test.ts
    • superset-frontend/packages/superset-ui-switchboard/src/switchboard.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

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>
@rusackas
rusackas force-pushed the ts6-migration/phase-e-small-leaves branch from 60db174 to 0793a8e Compare May 11, 2026 23:58
@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.03%. Comparing base (187bb41) to head (0793a8e).

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           
Flag Coverage Δ
javascript 66.91% <100.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.

@bito-code-review

bito-code-review Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #a4cdcc

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 0793a8e..0793a8e
    • superset-frontend/packages/superset-ui-switchboard/src/switchboard.test.ts
    • superset-frontend/packages/superset-ui-switchboard/src/switchboard.ts
  • Files skipped - 0

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

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!: MessagePort definite assignment assertion. Correct given the two-phase init design; all this.port accesses are gated by isInitialised guards so the runtime invariant holds.
  • switchboard.ts:100,102 — debugMode = false / isInitialised = false replacing bare type declarations. Strictly better: eliminates implicit undefined state.
  • switchboard.test.ts:98–102 — as unknown as MessagePort cast 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.

@rusackas
rusackas merged commit a75f9b6 into master May 20, 2026
72 checks passed
@rusackas
rusackas deleted the ts6-migration/phase-e-small-leaves branch May 20, 2026 22:37
kasiazjc pushed a commit that referenced this pull request May 26, 2026
….0 (Phase E) (#40028)

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

3 participants