effect-io-ai

Package: effect
Module: Struct

Struct.keys

Returns the string keys of a struct as a properly typed Array<keyof S & string>.

When to use

Use when you want a typed replacement for Object.keys that narrows the result to the known string keys of the struct.

Gotchas

Symbol keys are excluded; only string keys are returned.

Example (Reading typed keys)

import { Struct } from "effect"

const user = { name: "Alice", age: 30, [Symbol.for("id")]: 1 }

const k: Array<"name" | "age"> = Struct.keys(user)
console.log(k) // ["name", "age"]

See

Signature

declare const keys: <S extends object>(self: S) => Array<(keyof S) & string>

Source

Since v3.6.0