<K extends string | symbol = never, V = never>(): Record<
ReadonlyRecord.NonLiteralKey<K>,
V
>Creates a new, empty record.
Example (Creating an empty record)
import { Record } from "effect"
// Create an empty record
const emptyRecord = Record.empty<string, number>()
console.log(emptyRecord) // {}
// The type ensures type safety for future operations
const withValue = Record.set(emptyRecord, "count", 42)
console.log(withValue) // { count: 42 }constructors
Source effect/Record.ts:1694 lines
export const const empty: <
K extends string | symbol = never,
V = never
>() => Record<ReadonlyRecord.NonLiteralKey<K>, V>
Creates a new, empty record.
Example (Creating an empty record)
import { Record } from "effect"
// Create an empty record
const emptyRecord = Record.empty<string, number>()
console.log(emptyRecord) // {}
// The type ensures type safety for future operations
const withValue = Record.set(emptyRecord, "count", 42)
console.log(withValue) // { count: 42 }
empty = <function (type parameter) K in <K extends string | symbol = never, V = never>(): Record<ReadonlyRecord.NonLiteralKey<K>, V>K extends string | symbol = never, function (type parameter) V in <K extends string | symbol = never, V = never>(): Record<ReadonlyRecord.NonLiteralKey<K>, V>V = never>(): type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<
ReadonlyRecord.type ReadonlyRecord<in out K extends string | symbol, out A>.NonLiteralKey<K extends string | symbol> = K extends string ? ReadonlyRecord.IsFiniteString<K> extends true ? string : K : symbolRepresents a type that converts literal string keys to generic string type and symbol keys to generic symbol type.
This is useful for maintaining type safety while allowing flexible key types in record operations.
Example (Converting literal keys to non-literal keys)
import type { Record } from "effect"
// For literal string keys, this becomes 'string'
type Example1 = Record.ReadonlyRecord.NonLiteralKey<"foo" | "bar"> // string
// For symbol keys, this becomes 'symbol'
type Example2 = Record.ReadonlyRecord.NonLiteralKey<symbol> // symbol
NonLiteralKey<function (type parameter) K in <K extends string | symbol = never, V = never>(): Record<ReadonlyRecord.NonLiteralKey<K>, V>K>,
function (type parameter) V in <K extends string | symbol = never, V = never>(): Record<ReadonlyRecord.NonLiteralKey<K>, V>V
> => ({} as any)Referenced by 9 symbols