Skip to content

fix: add typesVersions fallback for clsx/lite (fixes #92) - #127

Open
3ni8ma wants to merge 2 commits into
lukeed:masterfrom
3ni8ma:fix/lite-typesversions-92
Open

fix: add typesVersions fallback for clsx/lite (fixes #92)#127
3ni8ma wants to merge 2 commits into
lukeed:masterfrom
3ni8ma:fix/lite-typesversions-92

Conversation

@3ni8ma

@3ni8ma 3ni8ma commented Sep 4, 2026

Copy link
Copy Markdown

Fixes #92.

Repro: TS project with moduleResolution node importing { clsx } from 'clsx/lite' fails with TS2307 before this change, passes after. bundler mode still passes.

Root cause: ./lite exposed only via exports map; classic node resolution ignores exports and looks for lite.d.ts at root.

Change: package.json adds typesVersions { *: { lite: [./clsx.d.ts] } }; readme notes bundler/nodenext/node16+ for full exports support.

Tests: npm run build + npm test green; tsc matrix node=pass, bundler=pass; CJS smoke clsx('hello', true && 'foo') => 'hello foo'. Trace snippet attached in comments.

@3ni8ma

3ni8ma commented Sep 4, 2026

Copy link
Copy Markdown
Author

tsc --traceResolution (TS 5.5.4, moduleResolution: node) after fix — local paths shortened to <repro>:

======== Resolving module 'clsx/lite' from '<repro>/check.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module 'clsx/lite' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Found 'package.json' at '<repro>/node_modules/clsx/package.json'.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '*' that matches compiler version '5.5.4', looking for a pattern to match module name 'lite'.
Module name 'lite', matched pattern 'lite'.
Trying substitution './clsx.d.ts', candidate module location: './clsx.d.ts'.
File '<repro>/node_modules/clsx/clsx.d.ts' exists - use it as a name resolution result.
======== Module name 'clsx/lite' was successfully resolved to '<repro>/node_modules/clsx/clsx.d.ts'. ========

Before the fix, the same project failed with TS2307: Cannot find module 'clsx/lite'. (Earlier version of this comment pasted raw local paths — replaced with the sanitized trace above; proof unchanged.)

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.

Cannot find module 'clsx/lite' or its corresponding type declarations

1 participant