Improve FieldsOf

This commit is contained in:
Michael B. Gale
2026-07-06 14:34:41 +01:00
parent e34d7fe5bf
commit d309c0e332

View File

@@ -42,12 +42,12 @@ export interface FeatureState {
/** Identifies a type of state an Action may have. */
export type StateFeature = keyof FeatureState;
/** Constructs the union of all state types identifies by `Fs`. */
/** Constructs the intersection of all state types identifies by `Fs`. */
export type FieldsOf<Fs extends readonly StateFeature[]> = Fs extends []
? BaseState
: Fs extends [
infer Head extends StateFeature,
...infer Tail extends StateFeature[],
...infer Tail extends readonly StateFeature[],
]
? FeatureState[Head] & FieldsOf<Tail>
: never;