effect-io-ai

Package: effect
Module: Predicate

Predicate.isPropertyKey

Checks whether a value is a valid PropertyKey (string, number, or symbol).

When to use

Use when you need a Predicate guard for unknown property keys before indexing.

Details

Uses isString, isNumber, and isSymbol.

Example (Guarding property keys)

import { Predicate } from "effect"

const key: unknown = "name"
const obj: Record<PropertyKey, unknown> = { name: "Ada" }

if (Predicate.isPropertyKey(key) && key in obj) {
  console.log(obj[key])
}

See

Signature

declare const isPropertyKey: (u: unknown) => u is PropertyKey

Source

Since v4.0.0