Skip to content

feat(types): add declaration reachability report (SD-2952 step 3)#3167

Merged
caio-pizzol merged 1 commit intomainfrom
caio-pizzol/SD-2952-reachability-report
May 5, 2026
Merged

feat(types): add declaration reachability report (SD-2952 step 3)#3167
caio-pizzol merged 1 commit intomainfrom
caio-pizzol/SD-2952-reachability-report

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

Stacked on #3165. SD-2952 step 3: instrument the dist with reachability data so we can decide which emitted declarations to trim in step 4.

Walks the public type graph from every typed package.json exports target (10 entries plus the converter/docx-zipper/file-zipper additions from #3165) and counts how many emitted .d.ts files are reachable from a consumer's TypeScript. Metric only - no CI gate on the ratio, per SD-2952's explicit guidance.

Initial measurement on the post-SD-2953 dist:

Reachable declarations: 442 / 2012 (22.0%) from 11 typed exports

  document-api    132 /  140 (94.3%)  - reach-driven emit, healthy
  layout-engine    71 /  137 (51.8%)  - moderate
  shared            0 /    3  (0.0%)  - tsc-postbuild emit reachable only via
                                         currently-unreachable CommentsLayer/types.d.ts
  super-editor    221 / 1642 (13.5%)  - primary trim target for step 4
  superdoc         18 /   90 (20.0%)  - internal helpers shipping with no consumer benefit

The 13.5% on super-editor is where step 4 (trim) should focus. The 0/3 on shared is informative about a dead-weight chain (CommentsLayer/types.d.ts holds the bare @superdoc/common reference that triggers the comments-types emit, but CommentsLayer/types.d.ts itself isn't on the public surface).

Script semantics:

  • Walker resolves relative imports + self-package superdoc/<subpath> via the package's exports map
  • External package specifiers (vue, prosemirror-, @tiptap/) ignored - they don't live in dist
  • Private workspace specifiers (@superdoc/*) ignored too; any surviving one is already a build failure via audit Rule 1
  • Sibling to audit-declarations.cjs (gate) - this one is metric-only
  • Wired into postbuild after check-export-coverage.cjs

Failure semantics: exit 1 on missing dist, malformed package.json, unreadable type entry, or unreadable .d.ts. Never exits non-zero on a low ratio.

Verified:

  • Clean build prints the metric + bucket breakdown
  • Synthetic missing-dist → exit 1
  • Synthetic malformed types target → exit 1
  • Restored → exit 0
  • Matrix stays 53/0/0

@caio-pizzol caio-pizzol requested a review from a team as a code owner May 5, 2026 16:22
@linear
Copy link
Copy Markdown

linear Bot commented May 5, 2026

@caio-pizzol caio-pizzol self-assigned this May 5, 2026
@caio-pizzol caio-pizzol force-pushed the caio-pizzol/SD-2953-runtime-only-types branch from e434a8b to ae23702 Compare May 5, 2026 17:35
Base automatically changed from caio-pizzol/SD-2953-runtime-only-types to main May 5, 2026 20:11
Walks the public type graph from every typed package.json exports
target and counts how many emitted .d.ts files are reachable from a
consumer's TypeScript. The output is data for the SD-2952 trim slice
(step 4); not a CI gate per the SD-2952 acceptance.

Initial measurement on the post-SD-2953 dist:

  Reachable declarations: 442 / 2012 (22.0%) from 11 typed exports

  document-api    132 /  140 (94.3%)  - reach-driven emit, healthy
  layout-engine    71 /  137 (51.8%)  - moderate
  shared            0 /    3  (0.0%)  - tsc-postbuild emit reachable
                                         only via currently-unreachable
                                         CommentsLayer/types.d.ts
  super-editor    221 / 1642 (13.5%)  - 1421 unreachable, primary
                                         trim target for step 4
  superdoc         18 /   90 (20.0%)  - 72 internal helpers shipping
                                         to no consumer benefit

Walker resolves relative imports + self-package `superdoc/<subpath>`
via the package's exports map. External package specifiers (vue,
prosemirror-*, @tiptap/*) are ignored - they don't live in dist.
Private workspace specifiers (@superdoc/*) are ignored too; any
surviving one is already a build failure via audit Rule 1.

Script is a sibling to audit-declarations.cjs (gate) - this one is
metric-only. Wired into postbuild after check-export-coverage.cjs.
Failure semantics: exit 1 on missing dist, malformed package.json,
unreadable type entry, or unreadable .d.ts files. Never exits non-
zero on a low ratio.

Verified end-to-end: clean run prints metrics + bucket breakdown;
synthetic missing-dist exits 1; synthetic malformed `types` target
exits 1; matrix stays 53/0/0.
@caio-pizzol caio-pizzol force-pushed the caio-pizzol/SD-2952-reachability-report branch from a2ccaf0 to b7ca7c6 Compare May 5, 2026 20:13
@caio-pizzol caio-pizzol merged commit e667344 into main May 5, 2026
21 of 22 checks passed
@caio-pizzol caio-pizzol deleted the caio-pizzol/SD-2952-reachability-report branch May 5, 2026 20:14
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 5, 2026

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

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-next.104

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 5, 2026

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

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 superdoc-cli v0.8.0-next.76

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 superdoc v1.30.0-next.59

The release is available on GitHub release

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 5, 2026

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

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