Skip to main content

Function: isSome()

isSome<T>(option): option is Some<T>

Defined in: option/guards/index.ts:20

Type guard to check if an Option is Some.

Narrows the type to Some.

Type Parameters

T

T

Parameters

option

Option<T>

The Option to check

Returns

option is Some<T>

True if the Option is Some

Example

const opt = some(42)

if (isSome(opt)) {
console.log(opt.value) // TypeScript knows this is safe
}