Skip to content

Move Feature enum to a separate file - #4298

Merged
mbg merged 1 commit into
mainfrom
mbg/decouple-features-enum
Nov 4, 2026
Merged

mbg merged 1 commit into
mainfrom
mbg/decouple-features-enum

Conversation

@mbg

@mbg mbg commented Nov 4, 2026

Copy link
Copy Markdown
Member

The feature-flags.ts module currently contains a number of definitions, including the Features enum and FeatureEnablement interface. Most consumers of feature flags only need to import Features and occasionally FeatureEnablement in order to query feature flags. However, feature-flags.ts also contains the feature flag "client" implementation which has a number of dependencies on other parts of the codebase.

Because Features is an enum and has a value-level representation, it cannot just be imported as type by consumers (unlike FeatureEnablement). Consequently, importing Features in modules that are themselves dependencies or transitively dependencies of feature-flags.ts is not possible and (in my experience) a frequent source of dependency cycles.

This PR moves the definition of Features into a separate file from which it can be imported by consumers that are dependencies of feature-flags.ts without introducing dependency cycles. For convenience, feature-flags.ts re-exports Features since it doesn't affect existing consumers and we don't have to update all of the import lists this way.

@mbg
mbg requested a review from a team as a code owner November 4, 2026 13:23
Copilot AI auto review requested due to automatic review settings November 4, 2026 13:23
@github-actions github-actions Bot added the size/M Should be of average difficulty to review label Nov 4, 2026

Copilot AI 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.

🟢 Approval recommended

No active review issues remain, and the change cleanly isolates the enum while preserving the existing public export.

No open issues 🎉

What changed in this PR

Moves the Feature enum into a standalone module so low-level consumers can import it without creating dependency cycles, while preserving the existing feature-flags.ts export.

Changes:

  • Added src/feature-flags/features.ts with the Feature enum.
  • Removed the inline enum definition from src/feature-flags.ts.
  • Re-exported Feature from src/feature-flags.ts for compatibility.
File Description
src/​feature-flags/​features.ts New standalone definition of the Feature enum.
src/​feature-flags.ts Imports the extracted enum and preserves its existing public export.

Review effort: Lite (auto)

@mbg
mbg added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit 8aab3d8 Nov 4, 2026
231 checks passed
@mbg
mbg deleted the mbg/decouple-features-enum branch November 4, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Should be of average difficulty to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants