refactor(types): remove _internal-shims.d.ts soft-landing mechanism (SD-2942)#3155
Merged
caio-pizzol merged 2 commits intomainfrom May 5, 2026
Merged
Conversation
…SD-2942)
After SD-2893 drained every shim entry to zero, the auto-generated
_internal-shims.d.ts file ships empty (header comments only). The
auto-capture mechanism that wrote it is no longer load-bearing: it
was a soft fallback that captured any unrelocated private @superdoc/*
specifier in dist d.ts files and silently shimmed it as `any`. With
the relocation rules + RULE1_ALLOWLIST + UNSHIMMED_PRIVATE_SPECIFIERS
now covering the entire workspace surface, that soft path mostly
swallows new private leaks instead of failing the build.
This change makes new leaks fail loudly:
- ensure-types.cjs: drop the workspace-imports scanning loops, the
shim-file write, the triple-slash reference injection, and the
SHIM_FORBIDDEN regression net (now redundant with the relocation
rules + audit Rule 1). Add an explicit unlink for any stale
_internal-shims.d.ts left over from prior builds.
- audit-declarations.cjs: update the rule documentation. Rule 1 now
fails for any unrelocated private @superdoc/* specifier; Rule 3
becomes a no-op in steady state (kept as defense against stale
tarballs or future re-introduction). The internalShimsPresent
graceful-handling already existed in audit code; no behavioral
change there.
A future PR that introduces a new private @superdoc/* import on the
public surface fails audit Rule 1 at build time. Verified with a
synthetic injection: import('@superdoc/some-new-private-pkg').T in a
public-reachable d.ts produces FAIL findings: private-specifiers and
exits 1.
Net diff: -167 +41 lines across the two scripts.
Verified: build:es clean (10 guarded packages, no shim file emitted),
consumer matrix 47/0/0, runtime smoke 4/4, dist has zero
_internal-shims references, negative test confirms hard-landing.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…942) The comment above the inline-replacement block was inherited from the pre-SD-2893 era and described two things that are no longer true after the shim drain: 1. "fall through to the ambient shim block below" — SD-2942 (this PR) removes the shim block, so non-main-entry @superdoc/common imports now resolve via the RELOCATION_RULES rewriter, not via a fallback shim. 2. "Comment, CommentContent, CommentJSON ... not on the public surface" — SD-2893 stack 6 (PR #3154) relocated these types via the bare @superdoc/common rule mapping to comments-types.d.ts. `Comment` is now publicly importable as `import type { Comment } from 'superdoc/super-editor'`. Replace the block with a description of what the inline-replacement step actually does today: handle the main entry's runtime-value imports (DOCX, PDF, HTML, getFileObject, compareVersions, BlankDOCX) which are not type-only and so the relocation rule cannot serve them.
Contributor
|
🎉 This PR is included in vscode-ext v2.3.0-next.98 |
Contributor
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.54 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in @superdoc-dev/react v1.2.0-next.96 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in superdoc-cli v0.8.0-next.72 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in superdoc-sdk v1.8.0-next.55 |
Contributor
|
🎉 This PR is included in superdoc v1.30.0-next.55 The release is available on GitHub release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Capstone follow-up to SD-2893. After every originally-shimmed package was relocated or guarded, the auto-generated
_internal-shims.d.tsfile ships empty. This PR removes the mechanism that wrote it.The shim mechanism was a soft fallback:
ensure-types.cjsscanned every dist d.ts forfrom '@superdoc/...'patterns and emitted adeclare module 'X' { export type Y = any; }block for each unrelocated specifier. With SD-2893 complete, that path mostly swallows new private leaks as silentanyinstead of failing the build.Net diff: -167 +41 lines across two scripts.
ensure-types.cjschanges:UNSHIMMED_PRIVATE_SPECIFIERS+ audit Rule 1 cover the same ground)._internal-shims.d.tsfrom prior builds.shouldSkipWorkspaceShimas policy documentation for future audit work.audit-declarations.cjschanges:@superdoc/*specifier on the public surface.internalShimsPresentgraceful-handling code stays as-is.Hard-landing verified end-to-end. Synthetic injection of
import('@superdoc/some-new-private-pkg').Tinto a public-reachable d.ts:Pre-SD-2942 the same injection would have been silently shimmed.
Verified:
pnpm --filter superdoc build:esclean (audit OK, 10 guarded packages, no shim file emitted)grep -r '_internal-shims' dist/returns zero matches