refactor(web): convert enums to as-const in subscription-list 🤖🤖🤖#34567
Open
jeanibarz wants to merge 3 commits intolanggenius:mainfrom
Open
refactor(web): convert enums to as-const in subscription-list 🤖🤖🤖#34567jeanibarz wants to merge 3 commits intolanggenius:mainfrom
jeanibarz wants to merge 3 commits intolanggenius:mainfrom
Conversation
e6dc40d to
b0f6577
Compare
Convert 7 TypeScript enums in the plugin-detail-panel/subscription-list components to as-const objects with companion type aliases: - SubscriptionListMode (types.ts) - CreateButtonType (create/types.ts) - AuthorizationStatusEnum, ClientTypeEnum (create/hooks/use-oauth-client-state.ts) - ApiKeyStep (create/hooks/use-common-modal-state.ts) - LogTypeEnum (log-viewer.tsx, file-local) - EditStep (edit/apikey-edit-modal.tsx, file-local) All consumers use EnumName.MEMBER as values or EnumName as types; no runtime reflection, so the conversion preserves the public API. Drops 7 entries from web/eslint-suppressions.json for the erasable-syntax-only/enums rule and removes file entries that became empty. Partially addresses langgenius#27998. Co-authored-by: Claude <noreply@anthropic.com>
Rename "enum" to "constant" in two test descriptors to match the refactor
in the parent commit:
- "should export CreateButtonType enum" -> "...constant"
- describe("Enum Exports") -> describe("Constant Exports")
Keeps test names truthful; neighboring test already uses the "constant"
phrasing (see "should export DEFAULT_METHOD constant"). No behavior change.
Co-authored-by: Claude <noreply@anthropic.com>
ab6afd0 to
439da92
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts 7 TypeScript enums in the
plugins/plugin-detail-panel/subscription-listcomponent tree toas constobjects with companion type aliases:SubscriptionListModesubscription-list/types.tsCreateButtonTypesubscription-list/create/types.tsAuthorizationStatusEnumcreate/hooks/use-oauth-client-state.tsClientTypeEnumcreate/hooks/use-oauth-client-state.tsApiKeyStepcreate/hooks/use-common-modal-state.tsLogTypeEnumsubscription-list/log-viewer.tsxEditStepsubscription-list/edit/apikey-edit-modal.tsxPartially addresses #27998.
Why this is safe
EnumName.MEMBERas a value orEnumNameas a type. Theas constobject + type alias pattern preserves both the exported name and the set of string values, so the public API is identical.Object.values/Object.keys/iteration) — checked with grep across the repo, so the special-case patterns from the dosubot comment on refactor(web): In TypeScript, the use of enums should be avoided. #27998 don't apply.Status[key as keyof typeof Status]) — all accesses are static member references.Pattern
Matches the convention from the merged batches (e.g. #33960, #33834) and my prior PR #34565:
Checklist
pnpm run type-check— 0 errorspnpm run lint:ci— 0 errors (3174 pre-existing warnings, none introduced)pnpm run teston the 10 affected test files (294 tests acrosssubscription-list/**/__tests__/)erasable-syntax-only/enumsentries fromweb/eslint-suppressions.json; left other suppressions for those files intact; dropped 4 file entries that became empty.