Skip to content

Expose package types via exports types conditions#207

Merged
dennisoelkers merged 1 commit into
mainfrom
fix/types-exports-condition
Jun 11, 2026
Merged

Expose package types via exports types conditions#207
dennisoelkers merged 1 commit into
mainfrom
fix/types-exports-condition

Conversation

@dennisoelkers

Copy link
Copy Markdown
Member

Under moduleResolution: bundler/node16/nodenext, type resolution follows the exports map. Since the map only had bare JS paths, TypeScript resolved types to the generated dist/index.d.ts, which omitted the type-only members (ColorScheme, ColorVariant, etc.) that were exposed only by the hand-written ambient types.d.ts. Consumers on those resolution modes got "has no exported member" errors.

  • Re-export the public types from lib/index.ts so the built dist/index.d.ts is self-describing.
  • Add a types condition to every exports subpath pointing at the generated declaration files.

The top-level types/ambient types.d.ts are kept for node10 back-compat, so the change is purely additive.

Under `moduleResolution: bundler`/`node16`/`nodenext`, type resolution
follows the `exports` map. Since the map only had bare JS paths, TypeScript
resolved types to the generated `dist/index.d.ts`, which omitted the
type-only members (`ColorScheme`, `ColorVariant`, etc.) that were exposed
only by the hand-written ambient `types.d.ts`. Consumers on those
resolution modes got "has no exported member" errors.

- Re-export the public types from `lib/index.ts` so the built
  `dist/index.d.ts` is self-describing.
- Add a `types` condition to every `exports` subpath pointing at the
  generated declaration files.

The top-level `types`/ambient `types.d.ts` are kept for `node10`
back-compat, so the change is purely additive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dennisoelkers dennisoelkers requested a review from linuspahl June 9, 2026 09:29
@dennisoelkers dennisoelkers merged commit ecde13f into main Jun 11, 2026
2 checks passed
@dennisoelkers dennisoelkers deleted the fix/types-exports-condition branch June 11, 2026 10:05
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.

2 participants