ARTICLE AD BOX
I'm building a React component library published as `@my-org/ui-kit`. The package uses subpath exports in `package.json`:
{ "name": "@my-org/ui-kit", "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }, "./components/table": { "types": "./dist/components/table/index.d.ts", "default": "./dist/components/table/index.js" }, "./hooks": { "types": "./dist/hooks/index.d.ts", "default": "./dist/hooks/index.js" } }, "typesVersions": { "*": { "components/table": ["./dist/components/table/index.d.ts"], "hooks": ["./dist/hooks/index.d.ts"] } } }In the consumer project(some other repository in the same machine):
**tsconfig.json:**
**package.json:**
"dependencies": { "@my-org/ui-kit": "file:/Users/rahulverma/git/ui-kit-foundation/packages/ui-kit", .. }**next.config.mjs**
const nextConfig = { typescript: { ignoreBuildErrors: true, }, output: "export", transpilePackages: ["@my-org/ui-kit"], } export default nextConfig**The problem:**
When I manually write the import, it works perfectly (no errors, types resolve correctly):
import { DataTable } from "@my-org/ui-kit/components/table"; // Works fine
However, VS Code **auto-import suggestions don't work** for subpath exports. When I type `DataT` in my code, VS Code does not suggest `DataTable` from `@my-org/ui-kit/components/table`.
// Typing "useSome" does NOT suggest: import { useSomething } from "@my-org/ui-kit"; // No suggestion // Typing "DataT" does NOT suggest: import { DataTable } from "@my-org/ui-kit/components/table"; // No suggestion**What I've tried:**
- Added `typesVersions` field
- Verified `.d.ts` files exist in dist
- Restarted TypeScript server
- Confirmed `moduleResolution: "bundler"` is set
- TypeScript 5.7.3, VS Code latest
**Questions:**
1. Is this a known limitation of TypeScript's auto-import for subpath exports?
2. Is there a way to enable auto-import for subpath exports without re-exporting everything from the main entry?
3. How do libraries like MUI, Radix, or Mantine handle this?
