Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2846 Type error when importing docx in CJS file with TypeScript modu… #2883

Merged
merged 2 commits into from
Dec 6, 2024

Conversation

dolanmiu
Copy link
Owner

@dolanmiu dolanmiu commented Dec 5, 2024

…leResolution set to node16

Resolves: #2846

@danewilson can you confirm if this is the correct change? Will this still work for UMD and IIFE?

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (df99f96) to head (59cb53c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2883   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          286       286           
  Lines         8370      8370           
  Branches      1400      1400           
=========================================
  Hits          8370      8370           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danewilson
Copy link

Unfortunately this isn't quite right, you need a separate declaration file for CJS and ESM. You can check this yourself by running npx @arethetypeswrong/cli -P . or npx publint in your project directory.

There's an open issue for the tool you're using to generate the declaration file discussing this exact issue. I'd recommend doing something like this but with this variation because you're using "type": "module".

Hope that helps.

@dolanmiu
Copy link
Owner Author

dolanmiu commented Dec 6, 2024

Thanks.

Now it passes for publint and @arethetypeswrong/cli

C:\Users\Dolan\Documents\Git\docx>npx @arethetypeswrong/cli -P .

docx v9.1.0

Build tools:
- [email protected]
- vite@^6.0.1

 No problems found 🌟


┌───────────────────┬──────────┐
│                   │ "docx"   │
├───────────────────┼──────────┤
│ node10            │ 🟢        │
├───────────────────┼──────────┤
│ node16 (from CJS) │ 🟢 (CJS)  │
├───────────────────┼──────────┤
│ node16 (from ESM) │ 🟢 (ESM)  │
├───────────────────┼──────────┤
│ bundler           │ 🟢        │
└───────────────────┴──────────┘
C:\Users\Dolan\Documents\Git\docx>npx publint   
docx lint results:
All good!

@dolanmiu dolanmiu merged commit e80a50d into master Dec 6, 2024
10 checks passed
@dolanmiu dolanmiu deleted the feature/correct-exports branch December 6, 2024 13:44
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.

Type error when importing docx in CJS file with TypeScript moduleResolution set to node16
2 participants