Skip to content

fix(typecheck): enable @ts-check on packages/superdoc/src/index.js#3478

Merged
caio-pizzol merged 1 commit into
mainfrom
caio-pizzol/SD-typecheck-jsdoc-index-drain
May 24, 2026
Merged

fix(typecheck): enable @ts-check on packages/superdoc/src/index.js#3478
caio-pizzol merged 1 commit into
mainfrom
caio-pizzol/SD-typecheck-jsdoc-index-drain

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

First debt drain on the JSDoc ratchet snapshot. packages/superdoc/src/index.js was the only file under packages/superdoc/ on the 103-entry public-reachable debt list; this PR moves it from "tracked debt" to "fully gated by // @ts-check". Snapshot count: 103 β†’ 102.

Tight diff: 2 files, +5/-3 lines.

Two type errors surfaced and got fixed

  1. ./core/theme/create-theme.ts import had an explicit .ts extension - TS rejects this without allowImportingTsExtensions. Changed to .js. The rest of the file already uses .js (the canonical convention), and packages/superdoc/src/public/index.ts:55-56 imports the same module via .js.

  2. '@superdoc/common/data/blank.docx?url' Vite asset import has no static type. Suppressed with // @ts-expect-error - same pattern src/public/index.ts already uses.

Why per-file @ts-expect-error instead of a global *?url ambient shim

I tried the cleaner ambient approach first (packages/superdoc/src/shims-url.d.ts declaring *?url). It let the import resolve cleanly, but vite-plugin-dts then preserved the @superdoc/common/data/blank.docx?url import statement in the emitted public/index.d.ts, which tripped audit-declarations.cjs's "private workspace specifier" rule. Per-file suppression keeps the import "unknown" from TS's perspective, which keeps it from leaking into the .d.ts. The longer-term fix (rewriting ?url specifiers in ensure-types.cjs so the ambient shim is safe) is a separate piece of work.

Verified

  • pnpm check:types β†’ PASS (tsc -b clean across all referenced projects)
  • pnpm check:public:superdoc β†’ PASS, 9 stages, 156s. The jsdoc-ratchet stage now reports OK 6 CHECKED_FILES clean; ratchet snapshot in sync with index.js properly accounted for via // @ts-check rather than the debt snapshot.
  • audit-declarations.cjs (postbuild) β†’ clean. No @superdoc/* specifier leak.

What this is NOT

  • Not a TS migration. The file stays .js; just type-checked.
  • No intended public-surface change. Same export blocks, same JSDoc typedef re-exports.
  • Not "fix everything in src/superdoc". Other files (stores/superdoc-store.js, core/surface-manager.js, core/create-app.js) are not on the public-reachable surface, so adding // @ts-check there wouldn't drain the snapshot. Pick those up only if the goal becomes "harden internals", not "drain known debt".

Snapshot diff

packages/superdoc/scripts/jsdoc-debt-snapshot.json: one line removed (packages/superdoc/src/index.js). 102 entries remain - all under packages/super-editor/src/editors/v1/**.

Drains one entry from jsdoc-debt-snapshot.json (103 β†’ 102) - the only
SuperDoc-package file on the public-reachable JSDoc surface that
wasn't yet gated.

Two type errors surfaced and got fixed:

1. `./core/theme/create-theme.ts` import had an explicit .ts
   extension, which TS rejects without `allowImportingTsExtensions`.
   Changed to .js to match the rest of the file's convention (and
   packages/superdoc/src/public/index.ts:55-56 imports the same module
   via .js).

2. The `'@superdoc/common/data/blank.docx?url'` Vite asset import has
   no type. Suppressed with `// @ts-expect-error` - same pattern
   src/public/index.ts already uses. A global `*?url` ambient
   declaration would resolve the import cleanly but lets the
   @superdoc/common specifier leak into the emitted .d.ts, which
   trips audit-declarations.cjs's private-workspace-specifier rule.
   The per-file suppression keeps the leak from happening.

Verified: pnpm check:types PASS; pnpm check:public:superdoc PASS,
9 stages, 156s. jsdoc-ratchet stage now reports
`6 CHECKED_FILES clean; ratchet snapshot in sync` with index.js
properly accounted for via // @ts-check rather than the debt
snapshot.
@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 0f1201e into main May 24, 2026
72 checks passed
@caio-pizzol caio-pizzol deleted the caio-pizzol/SD-typecheck-jsdoc-index-drain branch May 24, 2026 22:32
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