Repository navigation
fix: import export default class declarations correctly - #574
haigou-web wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthrough
ChangesDefault class import correction
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The default-exported class is now injected with default-import syntax. No actionable merge risk remains in this change. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
export default class being imported as a named importexport default class declarations correctly
|
Friendly note: the |
Fixes #541
Problem
export default class Foo {}was always imported as a named import:mlly'sfindExports()returns two entries for that source — adefaultone and adeclarationone, both starting at the same offset.scanExports()added a default import plus a named import plus a type import, and thendedupeImports()kept the wrong one: the correct{name: "default", as: "MyClass"}was dropped in favour of{name: "MyClass", as: "MyClass"}.Note this is specific to
class:export default function foo() {}yields only thedefaultentry, which is why the two behave differently.Fix
The declaration branch now skips entries that came from an
export defaultstatement, so only the default import survives. The type import is kept —MyClassis valid as a type, which is what mlly's change was for.Verification
test/default-class.test.tsexpected 'import { MyClass } from ...' to contain 'import MyClass from')tsc --noEmit: exit 0;eslint: exit 0Summary by CodeRabbit