Skip to content

refactor(web): convert 7 enums to as-const objects (batch 5)#33960

Merged
hyoban merged 2 commits into
langgenius:mainfrom
mahmoodhamdi:refactor/web-enums-batch-5
Mar 26, 2026
Merged

refactor(web): convert 7 enums to as-const objects (batch 5)#33960
hyoban merged 2 commits into
langgenius:mainfrom
mahmoodhamdi:refactor/web-enums-batch-5

Conversation

@mahmoodhamdi

Copy link
Copy Markdown
Contributor

Summary

  • Converted 7 TypeScript enum declarations to as const objects + companion type aliases
  • Files changed: types/model-provider.ts, types/workflow.ts, app/components/workflow/note-node/types.ts, app/components/workflow/variable-inspect/types.ts, app/components/rag-pipeline/components/panel/test-run/types.ts, app/components/rag-pipeline/components/chunk-card-list/types.ts
  • Converted enums: ModelProviderQuotaGetPaid, VarInInspectType, TestRunStep, QAItemType, NoteTheme, ViewMode, PreviewType
  • Disabled ts/no-redeclare rule (TypeScript handles this natively)
  • Removed corresponding erasable-syntax-only/enums suppressions

Why

TypeScript enums generate additional runtime code (IIFE wrappers), increasing bundle size unnecessarily. The as const pattern provides the same developer experience with zero runtime overhead.

Scope

Incremental step toward the full enum migration described in #27998. Kept the PR small and focused on type definition files with limited usage scope.

Checklist

Convert ModelProviderQuotaGetPaid, VarInInspectType, TestRunStep,
QAItemType, NoteTheme, ViewMode, and PreviewType from TypeScript
enums to as-const objects with companion type aliases.

Partially addresses langgenius#27998.
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 23, 2026
@github-actions github-actions Bot added the web This relates to changes on the web. label Mar 23, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request continues the ongoing migration from TypeScript enum declarations to as const objects, a strategic move aimed at optimizing bundle size by eliminating the unnecessary runtime code generated by traditional enums. This particular batch focuses on converting seven specific enums across various type definition files, ensuring the same robust developer experience while enhancing application performance. The changes also include necessary updates to ESLint configurations to properly support this modern TypeScript pattern.

Highlights

  • Enum Conversion: Converted 7 TypeScript enum declarations to as const objects with companion type aliases to reduce bundle size and improve runtime efficiency.
  • ESLint Configuration Update: Disabled the ts/no-redeclare ESLint rule and removed specific erasable-syntax-only/enums suppressions, aligning with the new as const pattern.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the needs revision for anti-slop label Mar 23, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request refactors multiple TypeScript enum declarations into const objects with as const assertions and corresponding type aliases across several files. This change also involved updating ESLint configurations to disable the ts/no-redeclare rule and removing related suppressions. Review comments suggest adding explanations for this refactoring to improve code maintainability and understanding. Additionally, an improvement opportunity was identified to remove a potentially redundant type cast in web/app/components/workflow/variable-inspect/right.tsx as TypeScript should now correctly infer the type.

Comment thread web/app/components/rag-pipeline/components/chunk-card-list/types.ts
Comment thread web/app/components/rag-pipeline/components/panel/test-run/types.ts
Comment thread web/app/components/workflow/note-node/types.ts
Comment thread web/app/components/workflow/variable-inspect/right.tsx
Comment thread web/app/components/workflow/variable-inspect/types.ts
Comment thread web/app/components/workflow/variable-inspect/types.ts
Comment thread web/types/model-provider.ts
Comment thread web/types/workflow.ts
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Mar 26, 2026
@hyoban hyoban added this pull request to the merge queue Mar 26, 2026
@hyoban hyoban merged commit 8ca54dd into langgenius:main Mar 26, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer needs revision for anti-slop refactor size:L This PR changes 100-499 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.

2 participants