Skip to content

Ship bundled .d.ts types + hosted TypeDoc API reference#128

Merged
PAMulligan merged 6 commits into
mainfrom
44-ship-dts-types-and-generate-an-api-reference-with-typedoc
Jun 17, 2026
Merged

Ship bundled .d.ts types + hosted TypeDoc API reference#128
PAMulligan merged 6 commits into
mainfrom
44-ship-dts-types-and-generate-an-api-reference-with-typedoc

Conversation

@PAMulligan

Copy link
Copy Markdown
Contributor

Summary

Guarantees consumers of claudius-chat-widget get full TypeScript IntelliSense, and adds an auto-generated, hosted API reference built from TSDoc.

  • Single bundled dist/index.d.ts via vite-plugin-dts (bundleTypes), replacing the old 37-file tsc --emitDeclarationOnly tree. A byte-identical index.d.cts twin plus per-condition exports make CJS require consumers resolve types correctly.
  • TSDoc on every public export reachable from src/index.ts (component + props, hooks, theme + tokens, i18n, locales, API client, errors, message/source types).
  • pnpm docs:api runs TypeDoc and emits HTML to widget/dist/api.
  • Hosted at claudius-docs.pages.dev/api/: the docs build copies the HTML into the Astro site (one domain, one deploy) and the sidebar links it under API Reference with a typedoc badge.
  • CI gates: docs:api:check fails on any undocumented public export (or broken @link); check:exports (publint + attw) proves the published types resolve.

Acceptance criteria

  • Vite build emits a single index.d.ts bundle
  • All public exports (ChatWidget, props, hooks, types) have TSDoc comments
  • pnpm docs:api runs TypeDoc and outputs HTML to dist/api
  • Generated reference published to Cloudflare Pages and linked from the docs site
  • CI fails if any public export lacks a TSDoc summary

Verification

  • Clean pnpm build → only dist/index.d.ts + dist/index.d.cts (no stray tree).
  • pnpm check:exports → publint clean; attw green for . across node10 / node16 (CJS+ESM) / bundler.
  • pnpm docs:api:check → 0 warnings (gate green).
  • 257 unit tests + 10 Playwright e2e tests pass; lint + prettier clean.
  • Visual: confirmed the rendered /api/ reference (all exports; per-prop docs with @defaultValue and {@link} cross-refs) and the docs sidebar link.

Notes

  • Bare /api/ is collision-free with the existing /api/rest and /api/widget content routes.
  • attw excludes the ./embed (IIFE script) and ./style.css entrypoints, which are intentionally typeless.
  • Production publish happens when the Docs workflow runs on main after merge (now also triggered by widget/**).
  • Design + plan: docs/plans/2026-06-16-typescript-types-api-reference*.md.

Closes #44

🤖 Generated with Claude Code

Paul Mulligan and others added 5 commits June 16, 2026 17:06
Planning docs for #44: single bundled index.d.ts via vite-plugin-dts, TypeDoc HTML hosted at /api/ on the docs domain, and a CI doc-coverage gate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace 'tsc --emitDeclarationOnly' (a 37-file .d.ts tree) with vite-plugin-dts (bundleTypes via api-extractor), producing a single dist/index.d.ts. Add an index.d.cts twin plus per-condition exports so CJS 'require' consumers resolve types. Add check:exports (publint --strict + attw) verifying the '.' entry resolves across node10/node16/bundler.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add TSDoc summaries to every export reachable from src/index.ts (ChatWidget + props, WidgetPosition, translations/i18n, locales, triggers, theme + tokens, ChatApiClient + options, error classes, and the message/source/request/response types) and export ResolveTranslationsOptions. Add typedoc.json that emits an HTML reference to dist/api and gates documentation coverage via validation.notDocumented + treatWarningsAsErrors. New scripts: docs:api (HTML) and docs:api:check (validate-only). pnpm docs:api:check passes with 0 warnings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…debar

Add docs/scripts/copy-api.mjs to copy ../widget/dist/api into public/api during the docs build (tolerant: warns and skips when the reference is absent, so docs-only local builds still work). Wire it into the build script, gitignore the generated public/api/, and add a 'Generated Reference (TypeDoc)' entry under the API Reference sidebar group linking to /api/. Verified the docs build emits dist/api/index.html.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…cs build

Widget CI now runs 'pnpm docs:api:check' (fails on any undocumented public export or broken @link) and 'pnpm check:exports' (publint + attw) after the build. The Docs workflow installs the widget and runs 'pnpm docs:api' before building so the generated HTML reference ships with the Cloudflare Pages deploy, and now also triggers on widget/** changes so the reference rebuilds when the public API changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@PAMulligan PAMulligan linked an issue Jun 16, 2026 that may be closed by this pull request
5 tasks
Storybook's Vite builder loads vite.config.ts, so vite-plugin-dts ran during 'storybook build' and failed: api-extractor looked for dist/index.d.ts, which only the library build produces. Guard the dts plugin behind process.env.STORYBOOK so it runs only for the library build. Verified locally: 'pnpm build' still emits dist/index.d.ts (+ .d.cts) and 'pnpm build-storybook' now succeeds.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 16, 2026

Copy link
Copy Markdown

Deploying chat-widget with  Cloudflare Pages  Cloudflare Pages

Latest commit: df0a03e
Status: ✅  Deploy successful!
Preview URL: https://f888a310.chat-widget-ejc.pages.dev
Branch Preview URL: https://44-ship-dts-types-and-genera.chat-widget-ejc.pages.dev

View logs

@PAMulligan PAMulligan self-assigned this Jun 17, 2026
@PAMulligan PAMulligan added the documentation Improvements or additions to documentation label Jun 17, 2026
@PAMulligan PAMulligan moved this from Todo to Done in PMDS Open Source Roadmap Jun 17, 2026
@PAMulligan
PAMulligan merged commit 64771fe into main Jun 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

Development

Successfully merging this pull request may close these issues.

Ship .d.ts types and generate an API reference with TypeDoc

1 participant