new <A extends Record<string, any> = {}>(
args: Types.VoidIfEmpty<{ readonly [P in keyof A]: A[P] }>
) => Readonly<A> & Pipeable.PipeableProvides a base class for immutable data types.
When to use
Use when you need a lightweight immutable value type with .pipe() support.
Details
Extend Class with a type parameter to declare fields. The constructor
accepts those fields as a single object argument. When there are no fields
the argument is optional. Instances are Readonly and Pipeable.
Example (Defining a value class)
import { Data, Equal } from "effect"
class Person extends Data.Class<{ readonly name: string }> {}
const mike1 = new Person({ name: "Mike" })
const mike2 = new Person({ name: "Mike" })
console.log(Equal.equals(mike1, mike2))
// trueexport const const Class: new <
A extends Record<string, any> = {}
>(
args: Types.VoidIfEmpty<{
readonly [P in keyof A]: A[P]
}>
) => Readonly<A> & Pipeable.Pipeable
Provides a base class for immutable data types.
When to use
Use when you need a lightweight immutable value type with .pipe() support.
Details
Extend Class with a type parameter to declare fields. The constructor
accepts those fields as a single object argument. When there are no fields
the argument is optional. Instances are Readonly and Pipeable.
Example (Defining a value class)
import { Data, Equal } from "effect"
class Person extends Data.Class<{ readonly name: string }> {}
const mike1 = new Person({ name: "Mike" })
const mike2 = new Person({ name: "Mike" })
console.log(Equal.equals(mike1, mike2))
// true
Class: new<function (type parameter) A in <A extends Record<string, any> = {}>(args: Types.VoidIfEmpty<{ readonly [P in keyof A]: A[P]; }>): Readonly<A> & Pipeable.PipeableA 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, any> = {}>(
args: Types.VoidIfEmpty<{
readonly [P in keyof A]: A[P]
}>
args: import TypesTypes.type VoidIfEmpty<S> =
keyof S extends never ? void : S
Conditional type that returns void if S is an empty object type,
otherwise returns S.
When to use
Use to erase an empty object type from an API result or parameter position.
VoidIfEmpty<{ readonly [function (type parameter) PP in keyof function (type parameter) A in <A extends Record<string, any> = {}>(args: Types.VoidIfEmpty<{ readonly [P in keyof A]: A[P]; }>): Readonly<A> & Pipeable.PipeableA]: function (type parameter) A in <A extends Record<string, any> = {}>(args: Types.VoidIfEmpty<{ readonly [P in keyof A]: A[P]; }>): Readonly<A> & Pipeable.PipeableA[function (type parameter) PP] }>
) => type Readonly<T> = {
readonly [P in keyof T]: T[P]
}
Make all properties in T readonly
Readonly<function (type parameter) A in <A extends Record<string, any> = {}>(args: Types.VoidIfEmpty<{ readonly [P in keyof A]: A[P]; }>): Readonly<A> & Pipeable.PipeableA> & import PipeablePipeable.Pipeable = class extends import PipeablePipeable.const Class: new () => PipeableProvides a base constructor whose instances implement the standard Pipeable.pipe
method.
When to use
Use when you need to define a class that supports Effect-style method
chaining through .pipe(...).
Class {
constructor(props: anyprops: any) {
super()
if (props: anyprops) {
var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.assign<this, any>(target: this, source: any): any (+3 overloads)Copy the values of all of the enumerable own properties from one or more source objects to a
target object. Returns the target object.
assign(this, props: anyprops)
}
}
} as any