<Bag extends Record<string, ConfigField<unknown>>>(
bag: Bag
): FrozenBag<Bag>Read-only view of a config: every field becomes a FixedField, so
.set won't compile against it. Touches no store state — the underlying keys
stay swappable for any handle that still holds the original. Hand a frozen
config to code that should only read.
export const const freeze: <
Bag extends Record<string, ConfigField<unknown>>
>(
bag: Bag
) => FrozenBag<Bag>
Read-only view of a config: every field becomes a
FixedField
, so
.set won't compile against it. Touches no store state — the underlying keys
stay swappable for any handle that still holds the original. Hand a frozen
config to code that should only read.
freeze = <
function (type parameter) Bag in <Bag extends Record<string, ConfigField<unknown>>>(bag: Bag): FrozenBag<Bag>Bag extends type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<string, interface ConfigField<A>A yieldable config field. yield* field reads its underlying Config
through the ambient provider. Read-only on its own;
SwappableField
adds the control methods — so swappability is a structural distinction, not a
stored marker flag.
ConfigField<unknown>>,
>(
bag: Bag extends Record<string, ConfigField<unknown>>bag: function (type parameter) Bag in <Bag extends Record<string, ConfigField<unknown>>>(bag: Bag): FrozenBag<Bag>Bag,
): type FrozenBag<Bag> = {
readonly [K in keyof Bag]: Bag[K] extends ConfigField<
infer A
>
? FixedField<A>
: Bag[K]
}
FrozenBag<function (type parameter) Bag in <Bag extends Record<string, ConfigField<unknown>>>(bag: Bag): FrozenBag<Bag>Bag> => const rebuildBag: <Out>(
bag: Record<string, ConfigField<unknown>>,
freezeName: (name: string) => boolean
) => Out
rebuildBag<type FrozenBag<Bag> = {
readonly [K in keyof Bag]: Bag[K] extends ConfigField<
infer A
>
? FixedField<A>
: Bag[K]
}
FrozenBag<function (type parameter) Bag in <Bag extends Record<string, ConfigField<unknown>>>(bag: Bag): FrozenBag<Bag>Bag>>(bag: Bag extends Record<string, ConfigField<unknown>>bag, () => true);