Effect CommunityEC
Effect Community3y ago
8 replies
adrian_g

Should `Struct.evolve` Set Value of Optional Property

should Struct.evolve be able to set value of an optional property which is not set on the input object? For example:
const myStruct: { a?: string | undefined; b: boolean } = {
  b: true,
}

console.log(Struct.evolve(
  myStruct,
  { a: _ => 'defined' },
))
// prints: { b: true }


while:
const myStruct: { a?: string | undefined; b: boolean } = {
  b: true,
  a: undefined,
}

console.log(Struct.evolve(
  myStruct,
  { a: _ => 'defined' },
))
// prints: { b: true, a: 'defined' }
Was this page helpful?