-
-
Notifications
You must be signed in to change notification settings - Fork 241
Fix broken enum exports in index.ts #2680
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🦋 Changeset detectedLatest commit: 3176525 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@copilot The issue should be that we incorrectly tag the runtime enums as |
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
You're absolutely right! The simpler approach is much better. I've simplified the fix to avoid tagging JavaScript enums as The fix now checks for JavaScript enums in Commit: 42eb018 |
@copilot I think we simply want to check if it's any kind of enum, as the other enum modes are also runtime artifacts. So checking if enums are enabled should be all that's needed. Do you agree? |
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Absolutely! You're correct that all enum modes create runtime artifacts:
I've updated the fix to check for any enum when enums are enabled: Commit: 72e5295 |
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2680 +/- ##
==========================================
- Coverage 25.26% 25.26% -0.01%
==========================================
Files 385 385
Lines 37085 37086 +1
Branches 1781 1781
==========================================
Hits 9369 9369
- Misses 27703 27704 +1
Partials 13 13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Enums were being exported as type-only from the main index.ts file, making the enum objects unusable as values and causing TypeScript error TS1362.
The Problem
In version 0.84, when enums were enabled, the generated index.ts file used:
This caused enum objects to be exported as types only, making them unusable as values:
The Solution
The fix prevents enums from being incorrectly tagged as
meta.kind = 'type'
during symbol registration. Instead of complex binding logic changes, the solution addresses the root cause directly:In
handleComponent
function: All enum modes are no longer tagged as'type'
, allowing them to be exported as values:The Result
All enum modes now work correctly as both values and types:
This ensures that all enum modes can be used as values:
javascript
:export const MyEnum = { ... } as const
✅typescript
:export enum MyEnum { ... }
✅typescript-const
:export const enum MyEnum { ... }
✅The fix is simple and surgical, addressing the root cause rather than working around symptoms. All existing functionality for regular types and other exports remains unchanged.
Fixes #2679.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.