Fix missing types when resolving cjs with require #16

Closed
tommasosotte-satispay wants to merge 1 commit from patch-1 into master
tommasosotte-satispay commented 2025-10-17 12:40:44 +02:00 (Migrated from github.com)

When typescript resolves types with cjs mode and require it will look for require in conditional exports but won't find types, and will ignore type field in the parent, leading to missing types.

I have this problem on node@20.16.0, typescript@5.9.3, in a lib using @codemirror/view@6.38.6.
Adding types to the export in package.json fixes it.

When typescript resolves types with cjs mode and require it will look for require in conditional exports but won't find types, and will ignore type field in the parent, leading to missing types. I have this problem on `node@20.16.0`, `typescript@5.9.3`, in a lib using `@codemirror/view@6.38.6`. Adding types to the export in package.json fixes it.
marijnh commented 2025-10-17 15:24:59 +02:00 (Migrated from github.com)

Though I don't remember precisely what the issue was, there was a reason why we ended up creating a .d.cts file to solve this problem in my other packages, so attached patch applies that solution here as well.

Though I don't remember precisely what the issue was, there was a reason why we ended up creating a .d.cts file to solve this problem in my other packages, so attached patch applies that solution here as well.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
marijn/style-mod!16
No description provided.