Skip to content

refactor(superdoc): close strict-null cluster in SuperDoc.js (SD-2867)#3084

Merged
caio-pizzol merged 3 commits into
mainfrom
caio/SD-2867-strict-null-cluster
May 2, 2026
Merged

refactor(superdoc): close strict-null cluster in SuperDoc.js (SD-2867)#3084
caio-pizzol merged 3 commits into
mainfrom
caio/SD-2867-strict-null-cluster

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol commented May 2, 2026

SD-2867 strict-null cluster, grouped PR. Closes all 40 TS2532 / TS18048 / TS2533 errors in packages/superdoc/src/core/SuperDoc.js using one consistent set of patterns. No more per-error stacking.

Three mechanisms cover the cluster:

  1. Class field declarations for store-state fields that #initVueApp populates synchronously inside #init (superdocStore, commentsStore, highContrastModeStore, app, pinia, readyEditors, pendingCollaborationSaves). Declared without initializers because the constructed instances aren't available at field-init time; this matches the existing pattern for users / version / whiteboard. Closes ~25 sites where TS thought the field could be undefined because the assignment lived in a separate method.

  2. InternalConfig cast at sites that read this.config.documents, this.config.modules, or this.config.layoutEngineOptions after #init has normalized them. InternalConfig (in core/types/index.ts) gains four required-field overrides (documents, modules, user, layoutEngineOptions) representing the runtime invariants #init always produces. Public Config is unchanged; only the internal augmentation type tightens. Closes ~13 sites.

  3. Make the runtime invariants real: #init now explicitly normalizes this.config.documents = this.config.documents || [] and this.config.layoutEngineOptions = this.config.layoutEngineOptions || {} after normalizeTrackChangesConfig. The modules || {} and user defaults already existed; this completes the set so every InternalConfig cast site has the value it claims. Note: normalizeTrackChangesConfig already populates layoutEngineOptions internally, so the explicit guard here is belt-and-suspenders rather than a fresh fix - it makes the invariant legible at the #init boundary instead of relying on a side effect of an unrelated helper.

Public surface is unchanged. The SuperDoc .d.ts emits the same config: Config field; the new class fields emit with their precise ReturnType<typeof useStoreFn> types (no any leaks). InternalConfig is not re-exported through the package entry, so consumers don't see the tightening.

Total errors in SuperDoc.js (under probed // @ts-check) drop from ~130 to ~102. Remaining categories (TS2339 cascade, TS2345, TS2322) land in subsequent SD-2867 grouped PRs per the updated ticket plan.

Verified:

  • pnpm --filter superdoc check:jsdoc → 3 gated files clean
  • pnpm --filter superdoc build:es → no FAIL-level findings
  • pnpm --filter superdoc audit:declarations → no FAIL-level findings
  • node tests/consumer-typecheck/typecheck-matrix.mjs → 33 passed, 0 failed

Must stay the same:

  • Public Config shape (no required fields added)
  • Consumer view of superdoc.config (still typed as Config)
  • Consumer view of superdoc.superdocStore / commentsStore (still emit Pinia store types; SD-2915 tracks the deep any cleanup separately)

Review: confirm InternalConfig changes don't leak into public .d.ts (they shouldn't since the type isn't re-exported); confirm the #init normalization changes aren't observable to consumers (no behavior change for configs that already pass these fields, and the documents: [] default already existed via the class-field initializer for the no-source case).

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

linear Bot commented May 2, 2026

@codecov-commenter

This comment was marked as outdated.

@caio-pizzol caio-pizzol merged commit a26f003 into main May 2, 2026
72 checks passed
@caio-pizzol caio-pizzol deleted the caio/SD-2867-strict-null-cluster branch May 2, 2026 11:37
@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.37

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