File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @bucketco/react-sdk" ,
3
- "version" : " 3.0.0-alpha.5 " ,
3
+ "version" : " 3.0.0-alpha.6 " ,
4
4
"license" : " MIT" ,
5
5
"repository" : {
6
6
"type" : " git" ,
Original file line number Diff line number Diff line change @@ -30,10 +30,6 @@ type MaterializedFeatures = keyof Features extends never
30
30
: Features ;
31
31
32
32
export type FeatureKey = keyof MaterializedFeatures ;
33
- export type FeatureConfig < TKey extends FeatureKey > =
34
- MaterializedFeatures [ TKey ] extends boolean
35
- ? never
36
- : MaterializedFeatures [ TKey ] ;
37
33
38
34
type ProviderContextType = {
39
35
client ?: BucketClient ;
@@ -167,18 +163,22 @@ type RequestFeedbackOptions = Omit<
167
163
"featureKey" | "featureId"
168
164
> ;
169
165
166
+ type EmptyConfig = {
167
+ key : undefined ;
168
+ payload : undefined ;
169
+ } ;
170
+
170
171
type Feature < TKey extends FeatureKey > = {
171
172
isEnabled : boolean ;
172
173
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 ;
182
182
track : ( ) => void ;
183
183
requestFeedback : ( opts : RequestFeedbackOptions ) => void ;
184
184
} ;
@@ -194,7 +194,9 @@ type Feature<TKey extends FeatureKey> = {
194
194
* }
195
195
* ```
196
196
*/
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 > {
198
200
const {
199
201
features : { isLoading } ,
200
202
client,
@@ -226,7 +228,7 @@ export function useFeature<TKey extends FeatureKey>(key: TKey): Feature<TKey> {
226
228
return feature . isEnabled ?? false ;
227
229
} ,
228
230
get config ( ) {
229
- return feature . config ?? { key : undefined , payload : undefined } ;
231
+ return feature . config as Feature < typeof key > [ "config" ] ;
230
232
} ,
231
233
} ;
232
234
}
You can’t perform that action at this time.
0 commit comments