Skip to content

refactor(superdoc): type optional event callback registration#3085

Merged
caio-pizzol merged 5 commits into
mainfrom
caio/SD-2867-type-mismatch-cluster
May 2, 2026
Merged

refactor(superdoc): type optional event callback registration#3085
caio-pizzol merged 5 commits into
mainfrom
caio/SD-2867-type-mismatch-cluster

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

SD-2867 Cluster C only: type-only fix for the EventEmitter registration sites in SuperDoc.js where Config.on* callbacks are typed as optional but the public Config makes them so.

  • Casts optional config callbacks at EventEmitter registration sites only — #initListeners (14 sites) and #addToolbar's toolbar.on('exception', ...) (1 site).
  • The cast is a module-private asEventListener<T> identity helper; runtime returns the exact same value EventEmitter would have received before, so there is no defaulting or guard behavior change. If a consumer ever passes undefined explicitly, EventEmitter sees the same undefined it would have without the wrapper.
  • Does not touch the runtime-default mismatches in Clusters A and B (initializer null vs typedef undefined, User typedef vs DEFAULT_USER shape) or the heterogeneous Cluster D fixes (provider widening, SearchMatch shape, DocumentMode literal, etc.). Those each have consumer-observable trade-offs and need a separate audit.

Boundary check (matters for SD-2828 / SD-2867 separation):
The asEventListener helper is declared at module scope inside SuperDoc.js, not on the class. grep -E "asEventListener|EventListener" packages/superdoc/dist/superdoc/src/core/SuperDoc.d.ts returns no matches — the helper does not appear in the emitted public declarations.

Verified:

  • pnpm --filter superdoc check:jsdoc → 3 gated files clean
  • pnpm --filter superdoc build:es → no FAIL-level findings
  • node tests/consumer-typecheck/typecheck-matrix.mjs → 33 passed, 0 failed
  • Closes 15 of the 44 TS2345/TS2322 sites in SuperDoc.js (exact cluster match).

@caio-pizzol caio-pizzol requested a review from a team as a code owner May 2, 2026 11:34
@linear
Copy link
Copy Markdown

linear Bot commented May 2, 2026

Base automatically changed from caio/SD-2867-strict-null-cluster to main May 2, 2026 11:37
@codecov-commenter

This comment was marked as outdated.

@caio-pizzol caio-pizzol merged commit 67b5c37 into main May 2, 2026
72 checks passed
@caio-pizzol caio-pizzol deleted the caio/SD-2867-type-mismatch-cluster branch May 2, 2026 12:00
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 2, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.34

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 2, 2026

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.76

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 2, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.78

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 2, 2026

🎉 This PR is included in superdoc v1.30.0-next.35

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 2, 2026

🎉 This PR is included in superdoc-cli v0.8.0-next.52

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 2, 2026

🎉 This PR is included in superdoc-sdk v1.8.0-next.38

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 7, 2026

🎉 This PR is included in superdoc-cli v0.9.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 7, 2026

🎉 This PR is included in superdoc v1.32.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 7, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.4.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 7, 2026

🎉 This PR is included in @superdoc-dev/react v1.3.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 7, 2026

🎉 This PR is included in vscode-ext v2.4.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 15, 2026

🎉 This PR is included in superdoc-sdk v1.9.0

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.

2 participants