Skip to content

Apply types-resolution fix to legacy/ subpath too#30

Merged
MaxGhenis merged 1 commit into
mainfrom
fix/legacy-types-resolution
May 9, 2026
Merged

Apply types-resolution fix to legacy/ subpath too#30
MaxGhenis merged 1 commit into
mainfrom
fix/legacy-types-resolution

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

Mirror the 0.8.1 fix (#29) to the legacy/ re-exports.

src/legacy/index.ts had export * from './tokens' and export * from './charts'. Vite emits dist/legacy/tokens.js / tokens.cjs and dist/legacy/charts.js / charts.cjs siblings to the tsc-emitted dist/legacy/tokens/index.d.ts and dist/legacy/charts/index.d.ts folders. Same file-shadowing-folder ambiguity, same outcome: TypeScript's bundler resolver picked the file (no types) and silently dropped every colors / typography / spacing / chartColors re-export from @policyengine/ui-kit/legacy.

A separate Batch B migration agent surfaced this when three repos (cbo-baseline-tracker, uk-spring-statement-2026, aspen-eitc-ctc) had to add local workarounds because @policyengine/ui-kit/legacy wasn't exposing the symbols. With this fix shipped, those workarounds can be simplified.

Fix

Pin to './tokens/index' and './charts/index' — same pattern as #29.

Test plan

  • bun run typecheck clean
  • bun run test — 26 files, 292 tests pass
  • bun run build clean
  • Reproduced fix against a file:-installed consumer with moduleResolution: "bundler" (import { colors, typography, spacing, chartColors } from "@policyengine/ui-kit/legacy" resolves cleanly)

🤖 Generated with Claude Code

The 0.8.1 fix in #29 only patched the main-entry re-exports. The same
file-shadowing-folder ambiguity affected src/legacy/index.ts, where
'export * from "./tokens"' was silently dropping every legacy color/
typography/spacing/chartColors symbol from `@policyengine/ui-kit/legacy`.

Mirror the fix: pin the re-exports to './tokens/index' and './charts/index'.
Verified with a fresh tsc --noEmit against a file:-installed build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-ui-kit Ready Ready Preview, Comment May 9, 2026 1:34pm

Request Review

@policyengine
Copy link
Copy Markdown
Contributor

policyengine Bot commented May 9, 2026

Sorry @MaxGhenis, only members of the PolicyEngine/core-developers team can invoke Claude Code.

@MaxGhenis MaxGhenis merged commit bc11473 into main May 9, 2026
4 checks passed
@MaxGhenis MaxGhenis deleted the fix/legacy-types-resolution branch May 9, 2026 13:35
MaxGhenis added a commit that referenced this pull request May 9, 2026
* Restore legacy colors.blue/colors.success and add consumer-types harness

Adversarial review of the merged 0.8.x line surfaced three real follow-ups:

1. The `/legacy` shim's `colors` was missing `blue` (Tailwind sky 50–900)
   and `success` (#22C55E) that @policyengine/design-system 0.2.0/0.3.0
   shipped. The snapshot copied into src/legacy/ for 0.8.0 came from a
   later workspace build that had already dropped both. Two consumer
   migrations (PolicyEngine/cbo-baseline-tracker#3,
   PolicyEngine/uk-spring-statement-2026#22) had to backfill the missing
   values locally — the canary that the shim wasn't a true 1:1 mirror.
   Restored under "Semantic colors" / "Blue accent palette" with a
   comment noting the migration story.

2. The migration JSDoc in src/legacy/index.ts told consumers to map
   `colors.gray[N]` → `palette.gray[N]` and `colors.text.warning` →
   `rootColorsLight['--text-warning']` without flagging that both
   silently change visible hex values (legacy gray is Tailwind-3
   #6B7280 etc.; canonical is Slate #64748B etc. — and `--text-warning`
   was darkened from Mantine orange.9 to Tailwind orange-700 in 0.6.0
   for WCAG AA). Annotated each pair as same-hex or value-shifting so
   bulk sed-replace doesn't silently regress consumers.

3. The bundler-resolution drop fixed in #29 / #30 (dist/<name>.js
   shadowing dist/<name>/index.d.ts under moduleResolution: "bundler")
   was masked because nothing in this repo type-checked the package as
   an external consumer. Added tests/consumer-types/ with a fixture
   exercising the main entry, the legacy/ subpath, and per-feature
   subpaths, plus a tsconfig with paths to dist/ and a vitest spawn of
   tsc --noEmit. CI now runs `bun run build` before `bun run test` so
   the harness sees fresh dist/ output.

Legacy color tests pin colors.blue[50/500/600/900] and colors.success
exactly so a future shim regression fails locally instead of in 18+
consumers. 295 tests pass (was 293, +2 for blue/success).

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

* Address round 2 nits: colors.info value drift, skip-hint, soften JSDoc

- src/legacy/index.ts: flag colors.info → semanticFills.info as a
  value-shifting pair (design-system 0.3.0 had Ant blue #1890FF; 0.4.0+
  and this shim use PE teal-700 #2C7A7B for brand consistency). Consumers
  bumping from 0.3.x will see a one-time blue→teal shift on info usages.
  Also softened the module-level JSDoc framing from 'shim mirroring
  design-system' to acknowledge that some values shifted between 0.3.0
  and 0.4.0 and that --text-{warning,error,success} are shim-only
  accessibility variants.
- tests/consumer-types/typecheck.test.ts: switch from describe.skipIf to
  an explicit it.skip with an actionable hint ("run `bun run build`")
  so a dev running `bun run test` cold sees why the harness didn't
  fire instead of silently missing.

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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