<S extends object>(self: S): Array<keyof S & string>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"]Source effect/Struct.ts:1682 lines
export const const keys: <S extends object>(
self: S
) => Array<keyof S & string>
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"]
keys = <function (type parameter) S in <S extends object>(self: S): Array<(keyof S) & string>S extends object>(self: S extends objectself: function (type parameter) S in <S extends object>(self: S): Array<(keyof S) & string>S): interface Array<T>Array<(keyof function (type parameter) S in <S extends object>(self: S): Array<(keyof S) & string>S) & string> =>
var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.keys(o: {}): string[] (+1 overload)Returns the names of the enumerable string properties and methods of an object.
keys(self: S extends objectself) as interface Array<T>Array<(keyof function (type parameter) S in <S extends object>(self: S): Array<(keyof S) & string>S) & string>