Skip to content

fix(superdoc): hide internal fields at source + repair node16 Config resolution (SD-2886)#3056

Merged
caio-pizzol merged 1 commit into
mainfrom
caio/SD-2886-strip-internal-fields
May 1, 2026
Merged

fix(superdoc): hide internal fields at source + repair node16 Config resolution (SD-2886)#3056
caio-pizzol merged 1 commit into
mainfrom
caio/SD-2886-strip-internal-fields

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

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

After SD-2880 (#3053) published `Config` and `SuperDocLayoutEngineOptions`, two internal-only fields became reachable through the public surface:

  • `Config.socket` - "Internal: ... do not pass from outside." Set by SuperDoc when `modules.collaboration.providerType === 'hocuspocus'`. A consumer who passes it from outside breaks the collaboration setup.
  • `SuperDocLayoutEngineOptions.semanticOptions` - "Internal-only ... intentionally not a stable public API in v1."

Two earlier attempts surfaced their own problems and were rejected:

  1. `stripInternal: true` in superdoc's tsconfig. Review found this would silently strip 100+ pre-existing `@internal`-tagged fields across super-editor (`ImageAttrs.id`, `ParagraphAttrs.paraId`, `TableAttrs.sdBlockId`, etc.) - a worse regression than the one this PR closes.
  2. `Omit<...>` at the typedef alias boundary. Review found this only narrowed the standalone `Config` alias. The nested `Config.layoutEngineOptions` still reached the un-Omitted `SuperDocLayoutEngineOptions`, and the `SuperDoc` constructor signature still took the un-Omitted `Config` - so `new SuperDoc({ socket })` still type-checked.

This patch removes both fields from the source `Config` and `SuperDocLayoutEngineOptions` interfaces in `core/types/index.ts` and adds `InternalConfig` / `InternalSuperDocLayoutEngineOptions` extensions for the runtime callsites that need the augmented shape. Public surface no longer carries either field anywhere it can be reached.

Side fix surfaced by the same review: the JSDoc `@typedef {import('./types').X}` form in `core/SuperDoc.js` and `core/surface-manager.js` did not resolve under TypeScript's node16 module resolution. The published constructor signature decayed to `any` for node16 consumers, and the constructor probe silently type-checked. Switched all 11 `import('./types')` usages to `import('./types/index.js')` so the path resolves under both bundler and node16.

The regression-net fixture under `tests/consumer-typecheck/` now covers all four reachable surfaces: standalone `Config` alias, standalone `SuperDocLayoutEngineOptions` alias, nested `Config.layoutEngineOptions`, and the `SuperDoc` constructor parameter. Each uses `@ts-expect-error` so a regression on any path fails CI with TS2578 ("Unused @ts-expect-error directive").

Verified: matrix passes 31/31; declaration audit reports no FAIL findings; published `.d.ts` no longer references `socket` or `semanticOptions` on any reachable public path.

@caio-pizzol caio-pizzol requested a review from a team as a code owner May 1, 2026 17:01
@linear
Copy link
Copy Markdown

linear Bot commented May 1, 2026

@caio-pizzol caio-pizzol force-pushed the caio/SD-2886-strip-internal-fields branch from 8364657 to 59d0fb4 Compare May 1, 2026 17:03
Base automatically changed from caio/SD-2880-export-public-typedefs to main May 1, 2026 17:16
@caio-pizzol caio-pizzol force-pushed the caio/SD-2886-strip-internal-fields branch from 59d0fb4 to 8fe5e29 Compare May 1, 2026 17:17
@caio-pizzol caio-pizzol changed the title fix(superdoc): strip @internal fields from published .d.ts (SD-2886) fix(superdoc): hide internal fields via Omit at public-export boundary (SD-2886) May 1, 2026
@caio-pizzol caio-pizzol force-pushed the caio/SD-2886-strip-internal-fields branch 3 times, most recently from 45d4bf2 to 59aa639 Compare May 1, 2026 17:32
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…resolution (SD-2886)

After SD-2880 published Config and SuperDocLayoutEngineOptions, two
fields the source explicitly marks as internal became reachable on the
public surface:

  - Config.socket. 'Internal: ... do not pass from outside.' Set by
    SuperDoc when modules.collaboration.providerType is 'hocuspocus';
    a consumer who passes it from outside breaks the collaboration
    setup.
  - SuperDocLayoutEngineOptions.semanticOptions. 'Internal-only ...
    intentionally not a stable public API in v1.' A consumer who
    pins a shape couples themselves to behavior we may break.

Earlier attempts and why they were wrong:

  1. stripInternal: true in superdoc's tsconfig. Review pass found
     this would silently strip 100+ pre-existing @internal-tagged
     fields across super-editor (ImageAttrs.id, ParagraphAttrs.paraId,
     TableAttrs.sdBlockId, etc.) — a worse regression than the one
     this PR closes.

  2. Omit<...> at the typedef alias boundary in superdoc/src/index.js.
     Review pass found this only narrowed the standalone Config alias.
     The nested Config.layoutEngineOptions still reached the un-Omitted
     SuperDocLayoutEngineOptions, and the SuperDoc constructor signature
     still took the un-Omitted Config — so `new SuperDoc({ socket })`
     and `{ layoutEngineOptions: { semanticOptions } }` still type-
     checked.

This patch removes both fields from the source `Config` and
`SuperDocLayoutEngineOptions` interfaces in core/types/index.ts and
adds InternalConfig / InternalSuperDocLayoutEngineOptions extensions
for the runtime callsites that need the augmented shape (SuperDoc.js's
this.config.socket assignments, etc.). Public surface no longer carries
either field anywhere it can be reached.

Side fix surfaced by the same review: the JSDoc `@typedef
{import('./types').X}` form in core/SuperDoc.js and core/surface-manager.js
did not resolve under TypeScript's node16 module resolution. The published
constructor signature decayed to `any` for node16 consumers, and the
constructor probe (`new SuperDoc({ socket: undefined })`) silently
type-checked. Switched all 11 `import('./types')` usages to
`import('./types/index.js')` so the path resolves under both bundler
and node16.

The regression-net fixture under tests/consumer-typecheck/ now covers
all four reachable surfaces: standalone Config alias, standalone
SuperDocLayoutEngineOptions alias, nested Config.layoutEngineOptions,
and the SuperDoc constructor parameter. Each uses @ts-expect-error so
a regression on any path fails CI with TS2578 ("Unused @ts-expect-error
directive").

Verified: matrix passes 31/31; declaration audit reports no FAIL
findings; published .d.ts no longer references socket or
semanticOptions on any reachable public path.
@caio-pizzol caio-pizzol force-pushed the caio/SD-2886-strip-internal-fields branch from 59aa639 to 50d7bee Compare May 1, 2026 17:43
@caio-pizzol caio-pizzol changed the title fix(superdoc): hide internal fields via Omit at public-export boundary (SD-2886) fix(superdoc): hide internal fields at source + repair node16 Config resolution (SD-2886) May 1, 2026
@caio-pizzol caio-pizzol merged commit 3e09cbe into main May 1, 2026
72 checks passed
@caio-pizzol caio-pizzol deleted the caio/SD-2886-strip-internal-fields branch May 1, 2026 18:15
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

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

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

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

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

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

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

🎉 This PR is included in superdoc v1.31.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 5, 2026

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

@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

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