Skip to content

Commit

Permalink
feat(FeatureFlags): broaden feature flag type to accept undefined (#4554
Browse files Browse the repository at this point in the history
)

* feat(FeatureFlags): loosen feature flag type to accept undefined

* chore: add changeset

* Update .changeset/grumpy-coats-worry.md

---------

Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
  • Loading branch information
joshblack and joshblack committed May 6, 2024
1 parent e094a39 commit ed31476
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-coats-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Broaden feature flag type for experimental FeatureFlags to accept undefined
7 changes: 5 additions & 2 deletions packages/react/src/FeatureFlags/FeatureFlagScope.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type FeatureFlags = {
[key: string]: boolean
[key: string]: boolean | undefined
}

export class FeatureFlagScope {
Expand All @@ -24,7 +24,10 @@ export class FeatureFlagScope {
flags: Map<string, boolean>

constructor(flags: FeatureFlags = {}) {
this.flags = new Map(Object.entries(flags))
this.flags = new Map()
for (const [key, value] of Object.entries(flags)) {
this.flags.set(key, value ?? false)
}
}

/**
Expand Down

0 comments on commit ed31476

Please sign in to comment.