Package: effect
Module: Struct
Merges two structs into a new struct. When both structs share a key, the
value from that (the second struct) wins.
When to use
Use when you want { ...self, ...that } with proper types.
Details
The result type is Simplify<Assign<S, O>>.
Example (Merging structs with overlapping keys)
import { pipe, Struct } from "effect"
const defaults = { theme: "light", lang: "en" }
const overrides = { theme: "dark", fontSize: 14 }
const config = pipe(defaults, Struct.assign(overrides))
console.log(config) // { theme: "dark", lang: "en", fontSize: 14 }
See
Assign – the type-level equivalentevolve – transform individual values instead of replacing themSignature
declare const assign: { <O extends object>(that: O): <S extends object>(self: S) => Assign<S, O>; <O extends object, S extends object>(self: S, that: O): Assign<S, O>; }
Since v4.0.0