TypeScript · Senior · Question 57 of 75
Why does a dual ESM/CJS package need separate declaration files (e.g. .d.mts and .d.cts)?
- ✓Correct answer: TypeScript interprets each declaration file in the module format implied by its extension or
package.json, so one file can't correctly describe both - 2To support older browsers
- 3Because
.d.tscan't containexport default
Explanation
Mismatches cause "masquerading" types and broken default imports. Tools like "Are the types wrong?" detect them.