Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow strict typing of useGate() gate parameter #14

Open
jkjustjoshing opened this issue Nov 29, 2023 · 1 comment
Open

Allow strict typing of useGate() gate parameter #14

jkjustjoshing opened this issue Nov 29, 2023 · 1 comment

Comments

@jkjustjoshing
Copy link

Issue

If I fat-finger a gate ID when calling useGate(), I want my typescript type checker to identify this.

Suggestion

Make the gateName variable be a GateName type. This type is by default string, but can be overridden by the consuming project with something like

declare module 'statsig-react' {
  export type GateName = 'my_gate_1' | 'my_gate_2'
}

Whenever I start using a new gate, the first step is to add it to this type, and when I remove a type I remove it from this type definition.

@tore-statsig
Copy link
Contributor

Thanks for the feedback!

This is a nice suggestion, I remember many people trying to maintain their own enums of gate names, and standardizing a way to do that would be nice. We've added this to our backlog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants