-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
refactor: remove const enum #9243
Conversation
Size ReportBundles
Usages
|
Thanks for your contribution. After the team discussion, we think we can keep enums but change them from |
That is very clever, Should I close this PR? |
You can do it in this PR or redo in a new one. It's up to you ❤️ |
I'll open another PR, thank you. |
@sxzz If we use this approach, we will need contain |
It’s ok. If it is not referenced, it will be removed by tree-shaking. |
Not all of them, some But you can see the results first and then decide. |
@yangmingshan hi, I create a plugin to inline enum, see https://github.com/vuejs/core/pull/9261/files#diff-52a2558e5292b080df0a8a6b519b0ed62af0605833abe1766af51524e1985a34. Maybe you can refer to this to continue improving your PR. |
const enum
caused many trouble for both user (#1228) and Vue itself. So this PR is trying to remove all theconst enum
in Vue codebase, with non-breaking way of course.For types I will use
union
type to replaceconst enum
, for runtime I will replaceconst enum
with literal value. It's not a breaking change becauseconst enum
is compatible withunion
type, so the code below can continue to work:Currently I only refactored the
@vue/reactivity
package as an example, and it works. I kept theconst enum
declaration and its exports for compatibility.Do you think this is worth a try? If so, please let me know so I can continue. Or if you don't think this is the right path, I'll stop there.