You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
const enums not supported in some transpilers #323
Hi @moltar - I am unable to reproduce this. I tried downloading the swc CLI, and ran it on src/event/cloudevent.ts where the Version enum is declared, and did not get any errors. It produced this transpiled JS:
Thanks @moltar. This really seems to be an issue with swc. By modifying your example to use ts-jest instead of swc the example runs without error.
npm t
> cloudevent-exp@1.0.0 test /home/lanceball/src/github.com/tmp/cloudevent-exp
> jest
PASS ./cloudevents.test.ts
Version
✓ should work (2 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 2.39 s
Ran all test suites.
@moltar I see your point to some degree (though the blog post you linked is 404), which is why we have modified the bot to never actually close an issue. But having the label is useful, imo.
Activity
moltar commentedon Aug 21, 2020
Never mind, seems to be an issue with
@swc-node/jest.moltar commentedon Aug 21, 2020
See swc-project/swc#940
Maybe this can refactored from enum to const as const approach?
[-]TypeError: Cannot read property 'V03' of undefined[/-][+]const enums not supported in some transpilers[/+]lance commentedon Aug 26, 2020
Hi @moltar - I am unable to reproduce this. I tried downloading the
swcCLI, and ran it onsrc/event/cloudevent.tswhere theVersionenum is declared, and did not get any errors. It produced this transpiled JS:Can you provide some steps to reproduce this?
moltar commentedon Aug 28, 2020
Here is a repro: https://github.com/moltar/cloudevent-exp
lance commentedon Sep 1, 2020
Thanks @moltar. This really seems to be an issue with swc. By modifying your example to use ts-jest instead of swc the example runs without error.
My modifications.
moltar commentedon Sep 3, 2020
It is an issue with SWC, and they did confirm it in the linked issue: swc-project/swc#940
But this is also a larger issue, because Babel also does not support const enums: babel/babel#8741
I don't use babel, but there is a large portion of TS users who do.
Here is a short explainer (not my article): https://ncjamieson.com/dont-export-const-enums/
github-actions commentedon Oct 4, 2020
This issue is stale because it has been open 30 days with no activity.
moltar commentedon Oct 4, 2020
Not stale
github-actions commentedon Feb 23, 2021
This issue is stale because it has been open 30 days with no activity.
moltar commentedon Feb 23, 2021
https://blog.benwinding.com/github-stale-bots/
https://news.ycombinator.com/item?id=25821092
lance commentedon Mar 3, 2021
@moltar I see your point to some degree (though the blog post you linked is 404), which is why we have modified the bot to never actually close an issue. But having the label is useful, imo.
github-actions commentedon Apr 3, 2021
This issue is stale because it has been open 30 days with no activity.