fix(superdoc): hide internal fields at source + repair node16 Config resolution (SD-2886)#3056
Conversation
8364657 to
59d0fb4
Compare
59d0fb4 to
8fe5e29
Compare
45d4bf2 to
59aa639
Compare
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.
59aa639 to
50d7bee
Compare
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.31 The release is available on GitHub release |
|
🎉 This PR is included in @superdoc-dev/react v1.2.0-next.74 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.3.0-next.76 |
|
🎉 This PR is included in superdoc v1.30.0-next.33 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-cli v0.8.0-next.49 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.8.0-next.35 |
|
🎉 This PR is included in superdoc-cli v0.8.0 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.8.0 |
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0 The release is available on GitHub release |
|
🎉 This PR is included in superdoc v1.31.0 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.3.0 |
|
🎉 This PR is included in @superdoc-dev/react v1.3.0 The release is available on GitHub release |
After SD-2880 (#3053) published `Config` and `SuperDocLayoutEngineOptions`, two internal-only fields became reachable through the public surface:
Two earlier attempts surfaced their own problems and were rejected:
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.