isSome

function isSome<T>(
    option,
): option is Readonly<{ __option: 'Some'; value: T }>;

Checks whether the given Option contains a value.

This function acts as a type guard, ensuring the value is a Some.

Type Parameters

Type ParameterDescription
TThe type of the contained value.

Parameters

ParameterTypeDescription
optionOption<T>The Option to check.

Returns

option is Readonly<{ __option: "Some"; value: T }>

true if the option is a Some, false otherwise.

Example

Checking for Some values.

isSome(some(42)); // true
isSome(none());   // false

See

On this page