Skip to content

refactor(web): convert enums to as-const in subscription-list 🤖🤖🤖#34567

Open
jeanibarz wants to merge 3 commits intolanggenius:mainfrom
jeanibarz:refactor/27998-as-const-plugins-subscription-list
Open

refactor(web): convert enums to as-const in subscription-list 🤖🤖🤖#34567
jeanibarz wants to merge 3 commits intolanggenius:mainfrom
jeanibarz:refactor/27998-as-const-plugins-subscription-list

Conversation

@jeanibarz
Copy link
Copy Markdown
Contributor

Summary

Converts 7 TypeScript enums in the plugins/plugin-detail-panel/subscription-list component tree to as const objects with companion type aliases:

Enum File Scope
SubscriptionListMode subscription-list/types.ts exported
CreateButtonType subscription-list/create/types.ts exported
AuthorizationStatusEnum create/hooks/use-oauth-client-state.ts exported
ClientTypeEnum create/hooks/use-oauth-client-state.ts exported
ApiKeyStep create/hooks/use-common-modal-state.ts exported
LogTypeEnum subscription-list/log-viewer.tsx file-local
EditStep subscription-list/edit/apikey-edit-modal.tsx file-local

Partially addresses #27998.

Why this is safe

  • All consumers use either EnumName.MEMBER as a value or EnumName as a type. The as const object + type alias pattern preserves both the exported name and the set of string values, so the public API is identical.
  • No runtime reflection on any of these enums (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.
  • No string-to-enum coercion (e.g. 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:

export const AuthorizationStatusEnum = {
  Pending: 'pending',
  Success: 'success',
  Failed: 'failed',
} as const
export type AuthorizationStatusEnum = typeof AuthorizationStatusEnum[keyof typeof AuthorizationStatusEnum]

Checklist

  • pnpm run type-check — 0 errors
  • pnpm run lint:ci — 0 errors (3174 pre-existing warnings, none introduced)
  • Tests pass — pnpm run test on the 10 affected test files (294 tests across subscription-list/**/__tests__/)
  • Removed the 7 erasable-syntax-only/enums entries from web/eslint-suppressions.json; left other suppressions for those files intact; dropped 4 file entries that became empty.
  • Husky pre-commit hook passed (ESLint, tsgo, knip, unit tests)
  • Avoids conflict with @mahmoodhamdi's open PR refactor(web): convert 8 enums to as-const objects (batch 6) #33962 (different file set)

@jeanibarz jeanibarz requested review from iamjoel and zhsama as code owners April 5, 2026 13:43
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 5, 2026
@github-actions github-actions Bot added needs-revision web This relates to changes on the web. and removed needs-revision labels Apr 5, 2026
@dosubot dosubot Bot added javascript Pull requests that update javascript code refactor labels Apr 5, 2026
@jeanibarz jeanibarz force-pushed the refactor/27998-as-const-plugins-subscription-list branch from e6dc40d to b0f6577 Compare April 17, 2026 17:45
jeanibarz and others added 2 commits April 23, 2026 20:45
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>
@jeanibarz jeanibarz force-pushed the refactor/27998-as-const-plugins-subscription-list branch from ab6afd0 to 439da92 Compare April 23, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code needs-revision refactor size:M This PR changes 30-99 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant