The value to check.
true
if the value is a PendingOption, narrowing to PendingOption<unknown>
.
const x = pendingOption(some(42));
const y = pendingOption(none<number>());
const z = some(42); // Not a PendingOption
expect(isPendingOption(x)).toBe(true);
expect(isPendingOption(y)).toBe(true);
expect(isPendingOption(z)).toBe(false);
if (isPendingOption(x)) {
expect(await x).toStrictEqual(some(42)); // Type narrowed to PendingOption<unknown>
}
Checks if a value is a PendingOption, narrowing its type to
PendingOption<unknown>
.This type guard verifies whether the input is a PendingOption, indicating it wraps a
Promise
resolving to an Option (either Some or None).