effect-io-ai

Package: effect
Module: Struct

Struct.assign

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

Signature

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>; }

Source

Since v4.0.0