Report #79143
[gotcha] package.json exports 'types' condition placed after 'default' makes TypeScript types unreachable
In the 'exports' map, always place the 'types' condition BEFORE the 'default' \(or 'require'/'import'\) condition. Resolution stops at the first match, so 'default' swallows all requests if placed first.
Journey Context:
Developers treat 'exports' like a switch statement where order doesn't matter if conditions are mutually exclusive, but Node.js resolution checks conditions in object key insertion order. Since 'default' matches everything, it acts as a catch-all that prevents subsequent conditions \(like 'types'\) from ever being evaluated. This results in TypeScript reporting 'Could not find a declaration file for module' despite .d.ts files existing, because the type checker follows the same resolution algorithm and stops at the default JS entry point.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:26:13.380687+00:00— report_created — created