Skip to content

fix: re export ts enum type#325

Closed
tmg0 wants to merge 4 commits intounjs:mainfrom
tmg0:fix/issue-318
Closed

fix: re export ts enum type#325
tmg0 wants to merge 4 commits intounjs:mainfrom
tmg0:fix/issue-318

Conversation

@tmg0
Copy link
Copy Markdown
Contributor

@tmg0 tmg0 commented Feb 6, 2024

🔗 Linked issue

Resolves #318

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Added the declaration field in Import to distinguish between dts and enum When transfer exports to imports in toImport function findExports will tag enum as declaration, after dedupe imports, enum can only be used as a value.

Maybe add a type in mlly ESMExport is a better way? Or edit the return value after findExports instead of adding a field to the Export type?

Fix typescript enum auto import error, enum should be import as both value and type.

Resolves #318

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@antfu
Copy link
Copy Markdown
Member

antfu commented Feb 6, 2024

Yeah I think it makes sense to have mlly support that information later.

/cc @pi0 does the interface fields looks good to you?

@pi0
Copy link
Copy Markdown
Member

pi0 commented Feb 6, 2024

Generally yes! I would probably name it declarationType in interface btw or something that hints it is only a type indicator. And PR is more than welcome upstream I can release asap 👍🏼

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (da1733b) 98.73% compared to head (f154082) 98.74%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #325   +/-   ##
=======================================
  Coverage   98.73%   98.74%           
=======================================
  Files          14       14           
  Lines        1822     1834   +12     
  Branches      371      374    +3     
=======================================
+ Hits         1799     1811   +12     
  Misses         23       23           

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

@tmg0 tmg0 closed this Feb 22, 2024
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.

Auto-import for enum is not working: TS2749: 'User' refers to a value, but is being used as a type

3 participants