Skip to content

feat: support export default class in declaration exports#320

Merged
pi0 merged 2 commits intounjs:mainfrom
ilyaliao:feat/class-type
Aug 22, 2025
Merged

feat: support export default class in declaration exports#320
pi0 merged 2 commits intounjs:mainfrom
ilyaliao:feat/class-type

Conversation

@ilyaliao
Copy link
Contributor

This PR introduces a new behavior that allows export default class statements to be recognized as both declaration and default exports.

Why

Previously, export default class Foo {} was only treated as a default export. However, default-exported class should also be available as type declarations for use cases like:

export default class Foo {}

function bar(foo: Foo) {
  return 'bar'
}

This enables better auto-import support in tools like unimport and unplugin-auto-import.

@codecov
Copy link

codecov bot commented Aug 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.84%. Comparing base (226a47b) to head (9615fcf).
⚠️ Report is 97 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #320      +/-   ##
==========================================
- Coverage   88.04%   83.84%   -4.20%     
==========================================
  Files           8        8              
  Lines        1062      811     -251     
  Branches      188      200      +12     
==========================================
- Hits          935      680     -255     
- Misses        127      131       +4     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ❤️

@pi0 pi0 merged commit e5e4c9d into unjs:main Aug 22, 2025
4 checks passed
@ilyaliao ilyaliao deleted the feat/class-type branch August 23, 2025 03:49
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.

2 participants