fix(registry): import same-named lib files with .ts extension

Merged
KO
3d ago
+51-27

What and why

shadcn add rewrites registry imports by matching the file basename. When a component ships ui/<name>.tsx and lib/<name>.ts, the lib import resolves to the UI file, and the installed component imports itself and fails to compile. 26 UI files were affected, including the Base UI multi-select.

This adds the .ts extension to those 26 imports, which makes the CLI resolve the lib file and write @/lib/<name> without the extension. allowImportingTsExtensions goes into tsconfig.json, which works because noEmit is already on. trace-waterfall re-exported its types with a separate export type ... from, which the CLI doesn't strip the extension from, so those types now come through the existing import instead.

tests/lib/lib-import-extension.test.ts fails when a UI file imports its same-named lib file without the extension. Without the fix it fails on 26 files.

Verified end to end: built the registry, served public/r locally and installed key-value-editor, trace-waterfall and secret-field into a fresh Next.js app. The imports come out as @/lib/<name> and the installed files typecheck.

Closes #135

Checklist

  • bun run typecheck, bun run lint and bun run test pass
  • Tests cover the change, including keyboard interaction for UI components