1 | import { ActionReducer, Selector } from './models';
|
2 | import { FeatureSelector, NestedSelectors } from './feature_creator_models';
|
3 | export interface FeatureConfig<FeatureName extends string, FeatureState> {
|
4 | name: FeatureName;
|
5 | reducer: ActionReducer<FeatureState>;
|
6 | }
|
7 | declare type Feature<AppState extends Record<string, any>, FeatureName extends keyof AppState & string, FeatureState extends AppState[FeatureName]> = FeatureConfig<FeatureName, FeatureState> & BaseSelectors<AppState, FeatureName, FeatureState>;
|
8 | declare type FeatureWithExtraSelectors<FeatureName extends string, FeatureState, ExtraSelectors extends SelectorsDictionary> = string extends keyof ExtraSelectors ? Feature<Record<string, any>, FeatureName, FeatureState> : Omit<Feature<Record<string, any>, FeatureName, FeatureState>, keyof ExtraSelectors> & ExtraSelectors;
|
9 | declare type BaseSelectors<AppState extends Record<string, any>, FeatureName extends keyof AppState & string, FeatureState extends AppState[FeatureName]> = FeatureSelector<AppState, FeatureName, FeatureState> & NestedSelectors<AppState, FeatureState>;
|
10 | declare type SelectorsDictionary = Record<string, Selector<Record<string, any>, unknown>>;
|
11 | declare type ExtraSelectorsFactory<FeatureName extends string, FeatureState, ExtraSelectors extends SelectorsDictionary> = (baseSelectors: BaseSelectors<Record<string, any>, FeatureName, FeatureState>) => ExtraSelectors;
|
12 | declare type NotAllowedFeatureStateCheck<FeatureState> = FeatureState extends Required<FeatureState> ? unknown : 'optional properties are not allowed in the feature state';
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export declare function createFeature<FeatureName extends string, FeatureState, ExtraSelectors extends SelectorsDictionary>(featureConfig: FeatureConfig<FeatureName, FeatureState> & {
|
23 | extraSelectors: ExtraSelectorsFactory<FeatureName, FeatureState, ExtraSelectors>;
|
24 | } & NotAllowedFeatureStateCheck<FeatureState>): FeatureWithExtraSelectors<FeatureName, FeatureState, ExtraSelectors>;
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | export declare function createFeature<FeatureName extends string, FeatureState>(featureConfig: FeatureConfig<FeatureName, FeatureState> & NotAllowedFeatureStateCheck<FeatureState>): Feature<Record<string, any>, FeatureName, FeatureState>;
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | export declare function createFeature<AppState extends Record<string, any>, FeatureName extends keyof AppState & string = keyof AppState & string, FeatureState extends AppState[FeatureName] = AppState[FeatureName]>(featureConfig: FeatureConfig<FeatureName, FeatureState> & NotAllowedFeatureStateCheck<FeatureState>): Feature<AppState, FeatureName, FeatureState>;
|
39 | export {};
|