File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @bucketco/react-sdk" ,
3- "version" : " 3.0.0-alpha.5 " ,
3+ "version" : " 3.0.0-alpha.6 " ,
44 "license" : " MIT" ,
55 "repository" : {
66 "type" : " git" ,
Original file line number Diff line number Diff line change @@ -30,10 +30,6 @@ type MaterializedFeatures = keyof Features extends never
3030 : Features ;
3131
3232export type FeatureKey = keyof MaterializedFeatures ;
33- export type FeatureConfig < TKey extends FeatureKey > =
34- MaterializedFeatures [ TKey ] extends boolean
35- ? never
36- : MaterializedFeatures [ TKey ] ;
3733
3834type ProviderContextType = {
3935 client ?: BucketClient ;
@@ -167,18 +163,22 @@ type RequestFeedbackOptions = Omit<
167163 "featureKey" | "featureId"
168164> ;
169165
166+ type EmptyConfig = {
167+ key : undefined ;
168+ payload : undefined ;
169+ } ;
170+
170171type Feature < TKey extends FeatureKey > = {
171172 isEnabled : boolean ;
172173 isLoading : boolean ;
173- config :
174- | {
175- key : string ;
176- payload : FeatureConfig < TKey > ;
177- }
178- | {
179- key : undefined ;
180- payload : undefined ;
181- } ;
174+ config : MaterializedFeatures [ TKey ] extends boolean
175+ ? EmptyConfig
176+ :
177+ | {
178+ key : string ;
179+ payload : MaterializedFeatures [ TKey ] ;
180+ }
181+ | EmptyConfig ;
182182 track : ( ) => void ;
183183 requestFeedback : ( opts : RequestFeedbackOptions ) => void ;
184184} ;
@@ -194,7 +194,9 @@ type Feature<TKey extends FeatureKey> = {
194194 * }
195195 * ```
196196 */
197- export function useFeature < TKey extends FeatureKey > ( key : TKey ) : Feature < TKey > {
197+ export function useFeature < TKey extends FeatureKey > (
198+ key : TKey ,
199+ ) : Feature < typeof key > {
198200 const {
199201 features : { isLoading } ,
200202 client,
@@ -226,7 +228,7 @@ export function useFeature<TKey extends FeatureKey>(key: TKey): Feature<TKey> {
226228 return feature . isEnabled ?? false ;
227229 } ,
228230 get config ( ) {
229- return feature . config ?? { key : undefined , payload : undefined } ;
231+ return feature . config as Feature < typeof key > [ "config" ] ;
230232 } ,
231233 } ;
232234}
You can’t perform that action at this time.
0 commit comments