Hyperlinkv0.8.0-beta.28

Option

Option.isOptionconsteffect/Option.ts:328
(input: unknown): input is Option<unknown>

Determines whether the given value is an Option.

When to use

Use to validate unknown values at runtime boundaries, such as type-narrowing in union types.

Details

  • Returns true for both Some and None instances
  • Acts as a type guard, narrowing the input to Option<unknown>

Example (Checking if a value is an Option)

import { Option } from "effect"

console.log(Option.isOption(Option.some(1)))
// Output: true

console.log(Option.isOption(Option.none()))
// Output: true

console.log(Option.isOption({}))
// Output: false
Source effect/Option.ts:3281 lines
export const isOption: (input: unknown) => input is Option<unknown> = option.isOption
Referenced by 2 symbols