Interview practice question
Publishing a package with correct types for ESM and CommonJS
Frontend Engineering · TypeScript · Experienced
Consumers of your internal TypeScript library report type errors depending on whether they use ESM or CommonJS. How do you fix the package?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- exports field with import/require conditions and types per condition.
- Separate builds or careful single format.
- Correct file extensions (.mjs/.cjs, .d.mts/.d.cts).
- Validate with "Are the types wrong?".
- Test in sample consumer projects.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.