$Record<Key, Value>Type-level representation returned by Record.
export interface interface $Record<Key extends Record.Key, Value extends Constraint>Type-level representation returned by
Record
.
$Record<function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key extends Record.interface Record.KeyConstraint for schemas that can be used as record keys.
Details
The key schema must decode and encode property keys (string, number, or
symbol) so it can describe object property names.
Key, function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value extends Constraint> extends
interface BottomLazy<out Ast extends SchemaAST.AST, out Rebuild extends Top, in out TypeParameters extends ReadonlyArray<Constraint> = readonly [], out TypeMutability extends Mutability = "readonly", out TypeOptionality extends Optionality = "required", out TypeConstructorDefault extends ConstructorDefault = "no-default", out EncodedMutability extends Mutability = "readonly", out EncodedOptionality extends Optionality = "required">Lazy Bottom variant for schema implementations that compute their public
views on demand.
When to use
Use as an implementation base for schema interfaces that must expose
Bottom behavior without forcing TypeScript to eagerly evaluate expensive
Type, Encoded, or service views.
Details
The laziness is purely type-level; runtime behavior is unchanged.
BottomLazy keeps the structural operations inherited from Bottom, but
erases the expensive schema views to unknown. Concrete schema interfaces can
then redeclare the precise views they expose. This keeps wide schemas such as
Struct and Union cheaper when generic code reads a single view, while
preserving their exact public types.
BottomLazy<
import SchemaASTSchemaAST.class Objectsclass Objects {
_tag: 'Objects';
propertySignatures: ReadonlyArray<PropertySignature>;
indexSignatures: ReadonlyArray<IndexSignature>;
encodingChecks: Checks | undefined;
getParser: (recur: (ast: AST) => SchemaParser.Parser) => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, recurParameter: (ast: AST) => AST, flipMerge: boolean, checks: Checks | undefined, encodingChecks: Checks | undefined) => Objects;
flip: (recur: (ast: AST) => AST) => AST;
recur: (recur: (ast: AST) => AST, recurParameter?: (ast: AST) => AST) => AST;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node for object-like schemas, including structs and records.
When to use
Use when constructing or inspecting AST nodes for structs or records rather
than array-like schemas.
Details
propertySignatures — named properties with their types (struct fields).
indexSignatures — index signature entries (record patterns), each with
a parameter AST for matching keys and a type AST for values.
An Objects node with no properties and no index signatures performs only a
non-nullish check: it accepts any value except null and undefined,
including primitive values.
Gotchas
Duplicate property names throw at construction time.
Example (Inspecting a struct AST)
import { Schema, SchemaAST } from "effect"
const schema = Schema.Struct({ name: Schema.String })
const ast = schema.ast
if (SchemaAST.isObjects(ast)) {
for (const ps of ast.propertySignatures) {
console.log(ps.name, ps.type._tag)
}
// "name" "String"
}
Objects,
interface $Record<Key extends Record.Key, Value extends Constraint>Type-level representation returned by
Record
.
$Record<function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key, function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value>
>
{
readonly "Type": Record.type Record.Type<Key extends Record.Key, Value extends Constraint> = Value extends {
readonly "~type.optionality": "optional";
} ? Value extends {
readonly "~type.mutability": "mutable";
} ? { [P in Key["Type"]]?: Value["Type"] | undefined; } : { readonly [P in Key["Type"]]?: Value["Type"] | undefined; } : Value extends {
readonly "~type.mutability": "mutable";
} ? { [P in Key["Type"]]: Value["Type"]; } : { readonly [P in Key["Type"]]: Value["Type"]; }
Computes the decoded object type for a record schema from its key and value
schemas.
Details
The key schema supplies the property keys and the value schema supplies each
property's decoded Type. Optional and mutable value schemas affect the
resulting property optionality and writability.
Type<function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key, function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value>
readonly "Encoded": Record.type Record.Encoded<Key extends Record.Key, Value extends Constraint> = Value extends {
readonly "~encoded.optionality": "optional";
} ? Value extends {
readonly "~encoded.mutability": "mutable";
} ? { [P in Key["Encoded"]]?: Value["Encoded"] | undefined; } : { readonly [P in Key["Encoded"]]?: Value["Encoded"] | undefined; } : Value extends {
readonly "~encoded.mutability": "mutable";
} ? { [P in Key["Encoded"]]: Value["Encoded"]; } : { readonly [P in Key["Encoded"]]: Value["Encoded"]; }
Computes the encoded object type for a record schema from the key and value
schemas' encoded types.
Details
Encoded-side optionality and mutability on the value schema determine whether
the encoded record properties are optional or writable.
Encoded<function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key, function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value>
readonly "DecodingServices": Record.type Record.DecodingServices<Key extends Record.Key, Value extends Constraint> = Key["DecodingServices"] | Value["DecodingServices"]Union of the decoding service requirements of a record's key schema and value
schema.
DecodingServices<function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key, function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value>
readonly "EncodingServices": Record.type Record.EncodingServices<Key extends Record.Key, Value extends Constraint> = Key["EncodingServices"] | Value["EncodingServices"]Union of the encoding service requirements of a record's key schema and value
schema.
EncodingServices<function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key, function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value>
readonly "~type.make.in": type Simplify<T> = { [K in keyof T]: T[K]; }Flattens intersection types into a single object type for readability.
When to use
Use when hovering over a type shows A & B & C instead of the merged shape.
Details
This helper is purely cosmetic at the type level and has no runtime effect.
It preserves readonly modifiers; use
Mutable
to strip them.
Example (Flattening an intersection)
import type { Struct } from "effect"
type Original = { a: string } & { b: number }
// Without Simplify, the type displays as `{ a: string } & { b: number }`
type Simplified = Struct.Simplify<Original>
// { a: string; b: number }
Simplify<Record.type Record.MakeIn<Key extends Record.Key, Value extends Constraint> = Value extends {
readonly "~encoded.optionality": "optional";
} ? Value extends {
readonly "~encoded.mutability": "mutable";
} ? { [P in Key["~type.make"]]?: Value["~type.make"] | undefined; } : { readonly [P in Key["~type.make"]]?: Value["~type.make"] | undefined; } : Value extends {
readonly "~encoded.mutability": "mutable";
} ? { [P in Key["~type.make"]]: Value["~type.make"]; } : { readonly [P in Key["~type.make"]]: Value["~type.make"]; }
Computes the input object type accepted when constructing a record value.
Details
Keys use the key schema's ~type.make type and values use the value schema's
~type.make type. Value optionality and mutability determine whether
properties are optional or writable.
MakeIn<function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key, function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value>>
readonly "~type.make": type Simplify<T> = { [K in keyof T]: T[K]; }Flattens intersection types into a single object type for readability.
When to use
Use when hovering over a type shows A & B & C instead of the merged shape.
Details
This helper is purely cosmetic at the type level and has no runtime effect.
It preserves readonly modifiers; use
Mutable
to strip them.
Example (Flattening an intersection)
import type { Struct } from "effect"
type Original = { a: string } & { b: number }
// Without Simplify, the type displays as `{ a: string } & { b: number }`
type Simplified = Struct.Simplify<Original>
// { a: string; b: number }
Simplify<Record.type Record.MakeIn<Key extends Record.Key, Value extends Constraint> = Value extends {
readonly "~encoded.optionality": "optional";
} ? Value extends {
readonly "~encoded.mutability": "mutable";
} ? { [P in Key["~type.make"]]?: Value["~type.make"] | undefined; } : { readonly [P in Key["~type.make"]]?: Value["~type.make"] | undefined; } : Value extends {
readonly "~encoded.mutability": "mutable";
} ? { [P in Key["~type.make"]]: Value["~type.make"]; } : { readonly [P in Key["~type.make"]]: Value["~type.make"]; }
Computes the input object type accepted when constructing a record value.
Details
Keys use the key schema's ~type.make type and values use the value schema's
~type.make type. Value optionality and mutability determine whether
properties are optional or writable.
MakeIn<function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key, function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value>>
readonly "Iso": Record.type Record.Iso<Key extends Record.Key, Value extends Constraint> = Value extends {
readonly "~type.optionality": "optional";
} ? Value extends {
readonly "~type.mutability": "mutable";
} ? { [P in Key["Iso"]]?: Value["Iso"] | undefined; } : { readonly [P in Key["Iso"]]?: Value["Iso"] | undefined; } : Value extends {
readonly "~type.mutability": "mutable";
} ? { [P in Key["Iso"]]: Value["Iso"]; } : { readonly [P in Key["Iso"]]: Value["Iso"]; }
Computes the iso object type for a record schema from the key schema's Iso
keys and the value schema's Iso values.
Iso<function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key, function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value>
readonly $Record<Key extends Record.Key, Value extends Constraint>.key: Key extends Record.Keykey: function (type parameter) Key in $Record<Key extends Record.Key, Value extends Constraint>Key
readonly $Record<Key extends Record.Key, Value extends Constraint>.value: Value extends Constraintvalue: function (type parameter) Value in $Record<Key extends Record.Key, Value extends Constraint>Value
}