Skip to content

refactor(types): JSDoc source of truth + declaration emit - #4480

Open
joshgoebel wants to merge 5 commits into
mainfrom
spike/types-emit
Open

refactor(types): JSDoc source of truth + declaration emit#4480
joshgoebel wants to merge 5 commits into
mainfrom
spike/types-emit

Conversation

@joshgoebel

Copy link
Copy Markdown
Member

Summary

  • Move public/private type definitions into src/lib/hljs_types.js (JSDoc) and stop treating hand-written ambient types/index.d.ts as the source of truth (Future: Possibly more automated type compilation #3157).
  • Add npm run types:emit (tsconfig.emit.json) to generate types/generated/**; package entry is a thin barrel over that output.
  • Wire node build to ship generated decls + types/private.d.ts (exports["./private"]); drop unused vuePlugin from the public type surface.

Notes

  • Consumers still use "types": "./types/index.d.ts"; named public types are explicit exports; private aliases are highlight.js/private only.
  • Generated files are committed for now; a CI drift check (types:emit && git diff --exit-code) is a natural follow-up.

Test plan

  • npm run types:emit (exit 0)
  • npm run test-parser
  • Smoke tsc consumer: default export + Mode / HLJSApi; private types not on main entry
  • Full npm test / node build pack types check

Add tsconfig.emit.json and npm run types:emit for a declaration-only
build of leaf modules. Annotate modes exports for clean Mode-typed
output; tighten regex JSDoc. Generated files land in types/generated/
for inspection; published types/index.d.ts is unchanged.

Refs #3157
Define public/private types in src/lib/hljs_types.js; source imports
those instead of ambient highlight.js modules. Expand types:emit to
core + lib, replace types/index.d.ts with a thin barrel over
types/generated, and ship generated decls in the node build.

Refs #3157
Drop MatchType/Keyword* typedef re-exports from highlight.js; use
inline import() for internals. Barrel lists public types only; private
types ship as types/private.d.ts (exports ./private).

Refs #3157
Vue support lives in highlightjs/vue-plugin; it was never on the core
runtime export.

Refs #3157
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

7 files changed

Total change +59 B

View Changes
file base pr diff
es/core.min.js 8.22 KB 8.23 KB +14 B
es/highlight.min.js 8.22 KB 8.23 KB +14 B
es/languages/fsharp.min.js 2.08 KB 2.08 KB +3 B
es/languages/swift.min.js 3.68 KB 3.69 KB +4 B
highlight.min.js 8.26 KB 8.27 KB +18 B
languages/fsharp.min.js 2.09 KB 2.09 KB +3 B
languages/swift.min.js 3.69 KB 3.69 KB +3 B

install() does not create parent dirs; types/generated/lib/** failed
on CI with ENOENT.

Refs #3157
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

7 files changed

Total change +62 B

View Changes
file base pr diff
es/core.min.js 8.22 KB 8.24 KB +15 B
es/highlight.min.js 8.22 KB 8.24 KB +15 B
es/languages/fsharp.min.js 2.08 KB 2.08 KB +3 B
es/languages/swift.min.js 3.68 KB 3.69 KB +4 B
highlight.min.js 8.26 KB 8.28 KB +19 B
languages/fsharp.min.js 2.09 KB 2.09 KB +3 B
languages/swift.min.js 3.69 KB 3.69 KB +3 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant