refactor(web): convert ValidatedStatus enum to as-const in key-valida…#35749
Merged
crazywoola merged 3 commits intoMay 4, 2026
Conversation
…tor/declarations.ts Closes langgenius#27998 The ValidatedStatus enum generates runtime code that inflates the bundle. Convert to an as-const object with a type alias instead: Before: export enum ValidatedStatus { Success = 'success', Error = 'error', Exceed = 'exceed', } After: export const ValidatedStatus = { Success: 'success', Error: 'error', Exceed: 'exceed', } as const export type ValidatedStatus = typeof ValidatedStatus[keyof typeof ValidatedStatus] All 65 call sites use ValidatedStatus.Success / .Error / .Exceed property access and type annotations — no changes needed there.
crazywoola
approved these changes
May 4, 2026
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.
…tor/declarations.ts
Closes #27998
The ValidatedStatus enum generates runtime code that inflates the bundle. Convert to an as-const object with a type alias instead:
Before:
export enum ValidatedStatus {
Success = 'success',
Error = 'error',
Exceed = 'exceed',
}
After:
export const ValidatedStatus = {
Success: 'success',
Error: 'error',
Exceed: 'exceed',
} as const
All 65 call sites use ValidatedStatus.Success / .Error / .Exceed property access and type annotations — no changes needed there.
Important
Fixes #<issue number>.Description
What problem does this PR solve?
Issue link: Closes #27998
What did this PR do?
Converts the
ValidatedStatusTypeScript enum inweb/app/components/header/account-setting/key-validator/declarations.tsto anas-constobject with a type alias.Before:
After:
Why:
TypeScript enums generate runtime IIFE boilerplate that inflates the bundle. The
as-constpattern produces zero runtime overhead while preserving the same dot-notation access (ValidatedStatus.Success) and TypeScript type safety.Scope:
All 65 call sites use
ValidatedStatus.Success / .Error / .Exceedproperty access or type annotations — they continue to work unchanged.Checklist