@ts-rust/std - v0.0.5
    Preparing search index...

    Function isOption

    • Checks if a value is an Option, narrowing its type to Option<unknown>.

      This type guard verifies whether the input conforms to the Optional interface, indicating it is either a Some or None.

      Parameters

      • x: unknown

        The value to check.

      Returns x is Option<unknown>

      true if the value is an Option, narrowing to Option<unknown>.

      const x = some(42);
      const y = none<number>();
      const z = "not an option";

      expect(isOption(x)).toBe(true);
      expect(isOption(y)).toBe(true);
      expect(isOption(z)).toBe(false);

      if (isOption(x)) {
      expect(x.isSome()).toBe(true); // Type narrowed to Option<unknown>
      }