Skip to content

ci(superdoc): close 3 known declaration leaks and flip audit to strict (SD-2859)#3033

Merged
caio-pizzol merged 1 commit intomainfrom
caio-pizzol/SD-2859-audit-strict-default
Apr 30, 2026
Merged

ci(superdoc): close 3 known declaration leaks and flip audit to strict (SD-2859)#3033
caio-pizzol merged 1 commit intomainfrom
caio-pizzol/SD-2859-audit-strict-default

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

The declaration audit (SD-2832, merged into main via #3017) was running in informational mode because three pre-existing leaks the narrowed audit had surfaced were still open. Closes all three so strict mode is the default; from this PR forward, a new private-specifier leak in published declarations fails CI rather than warns.

Leak 1 (closed): Unused ambient declaration file super-editor/src/editors/v1/types/converter-internal.d.ts shipped to superdoc's dist via the SD-2842 hand-written-d.ts copy step. The file declares two @superdoc/super-editor/converter/internal/v3/handlers/w/{pPr,rpr}/index.js modules that no shipped code imports. Added a HANDWRITTEN_DTS_BLOCKLIST so internal-only ambient files like this stay in source for super-editor's own typecheck but do not ship.

Leak 2 (closed): @superdoc/common (root) leaked from three reachable d.ts files (commentsExporter.d.ts, node-translator.d.ts, CommentsLayer/types.d.ts). The existing strip-and-inline logic only handled superdoc/src/index.d.ts. Removed the @superdoc/common special-cases from the shim-skip predicates so the bare specifier in those files routes through the standard shim generator. The internal types it carries (Comment, CommentContent, CommentJSON) are not on the public surface, so collapsing them to any via the shim is safe; the strip-and-inline still runs for the main entry where the real DOCX / PDF / HTML constants are needed.

Leak 3 (uncovered while fixing leak 2): once @superdoc/common/components/BasicUpload.vue started flowing through the shim generator's named-import path, the file's import { default as BasicUpload } triggered the generator to emit export type default = any;, which is invalid TypeScript because default is a reserved word. Updated the generator to emit a proper export default declaration when default appears in the collected names.

Default flipped to strict: the audit script's default is now non-zero exit on FAIL findings. --informational (or SUPERDOC_AUDIT_INFORMATIONAL=1) is the explicit opt-out for local iteration on a known leak before the fix is ready. Replaced the redundant audit:declarations:strict npm script with audit:declarations:informational.

Verified locally:

  • Build: ✓ exit 0 (postbuild's audit step now actually fails on findings; passing means clean).
  • Audit: 0 FAIL findings; 9 modules remain in _internal-shims.d.ts (informational), all internal-only types not on the public surface.
  • Consumer matrix: 17/17 required pass.
  • Repo type-check: ✓.
  • superdoc unit tests: 60 files / 943 tests pass.
  • super-editor unit tests: previously verified green on the same source.
  • React type-check: ✓.
  • Template-builder build: ✓.

…t (SD-2859)

The audit gate was running in informational mode because the published surface had three pre-existing leaks the narrowed audit (SD-2832 follow-up) had surfaced. Closing all three so strict mode can be the default.

Leak 1: an unused ambient declaration file `super-editor/src/editors/v1/types/converter-internal.d.ts` was getting copied into superdoc's published dist by the SD-2842 hand-written-d.ts copy step. The file declares two `@superdoc/super-editor/converter/internal/v3/handlers/w/{pPr,rpr}/index.js` modules that no shipped code imports. Adds a `HANDWRITTEN_DTS_BLOCKLIST` to the copy step so internal-only ambient files like this one stay in source for super-editor's own typecheck but do not ship in superdoc's published surface.

Leak 2: `@superdoc/common` (root specifier) leaked from three files (`commentsExporter.d.ts`, `node-translator.d.ts`, `CommentsLayer/types.d.ts`). The existing strip-and-inline logic only handled `superdoc/src/index.d.ts`. Removed the `@superdoc/common` special-cases from the shim-skip predicates so the bare specifier in those files routes through the standard shim generator. The internal types it carries (Comment, CommentContent, CommentJSON) are not on the public surface, so collapsing them to `any` via the shim is safe; the strip-and-inline still runs for the main entry where the real DOCX/PDF/HTML constants etc. are needed.

Leak 3 (uncovered while fixing leak 2): once `@superdoc/common/components/BasicUpload.vue` started flowing through the shim generator's named-import path, the file's `import { default as BasicUpload }` triggered the generator to emit `export type default = any;` which is invalid TypeScript (`default` is a reserved word). Updated the generator to emit a proper `export default` declaration when `default` appears in the names set.

With all three fixed, the audit reports zero FAIL findings and the script now defaults to strict mode. `--informational` (or `SUPERDOC_AUDIT_INFORMATIONAL=1`) is the explicit opt-out for local iteration on a known leak. The redundant `audit:declarations:strict` npm script is replaced with `audit:declarations:informational` so the inverted default is reachable.

Verified: build green, audit clean in strict mode, consumer matrix 17/17, repo type-check green, superdoc unit tests 60/60 (943 tests), template-builder build green, react type-check green.
@caio-pizzol caio-pizzol requested a review from a team as a code owner April 30, 2026 21:46
@linear
Copy link
Copy Markdown

linear Bot commented Apr 30, 2026

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@caio-pizzol caio-pizzol merged commit fb30be2 into main Apr 30, 2026
63 checks passed
@caio-pizzol caio-pizzol deleted the caio-pizzol/SD-2859-audit-strict-default branch April 30, 2026 22:03
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

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

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

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

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

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

@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

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