Hyperlinkv0.8.0-beta.28

Types

Types.Mutabletypeeffect/Types.ts:478
Mutable<T>

Removes readonly from all properties of T. Supports arrays, tuples, and records.

When to use

Use when you need a mutable version of a readonly type.

Details

Only affects the top level; nested properties remain readonly.

Example (Converting shallowly to mutable types)

import type { Types } from "effect"

type Obj = Types.Mutable<{
  readonly a: string
  readonly b: ReadonlyArray<number>
}>
// { a: string; b: ReadonlyArray<number> }
//   ^ mutable    ^ still readonly inside

type Arr = Types.Mutable<ReadonlyArray<string>>
// string[]

type Tup = Types.Mutable<readonly [string, number]>
// [string, number]
Source effect/Types.ts:4783 lines
export type Mutable<T> = {
  -readonly [P in keyof T]: T[P]
}
Referenced by 10 symbols