File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { Env } from "./environment" ;
2+ import { FeatureEnablement } from "./feature-flags" ;
3+ import { Logger } from "./logging" ;
4+
5+ /** Describes different state features that an Action may have. */
6+ export interface FeatureState {
7+ Logger : {
8+ /** The logger that is in use. */
9+ logger : Logger ;
10+ } ;
11+ Env : {
12+ /** Information about environment variables. */
13+ env : Env ;
14+ } ;
15+ FeatureFlags : {
16+ /** Information about enabled feature flags. */
17+ features : FeatureEnablement ;
18+ } ;
19+ }
20+
21+ /** Identifies a type of state an Action may have. */
22+ export type StateFeature = keyof FeatureState ;
23+
24+ /** Constructs the union of all state types identifies by `Fs`. */
25+ export type FieldsOf < Fs extends readonly StateFeature [ ] > = Fs extends [
26+ infer Head extends StateFeature ,
27+ ]
28+ ? FeatureState [ Head ]
29+ : Fs extends [
30+ infer Head extends StateFeature ,
31+ ...infer Tail extends StateFeature [ ] ,
32+ ]
33+ ? FeatureState [ Head ] & FieldsOf < Tail >
34+ : never ;
35+
36+ /** Describes the state of an Action that has access to the state corresponding to `Fs`. */
37+ export type ActionState < Fs extends readonly StateFeature [ ] > = FieldsOf < Fs > ;
You can’t perform that action at this time.
0 commit comments