• Checks if assertion is valid and returns value with type inferred from the assertion.

    Type Parameters

    • $Value

    Parameters

    • assertion: Assertion<$Value>

      Assertion to be checked.

    • value: unknown

      Value to be passed into assertion.

    Returns $Value

    parse(number, 1); // 1
    parse(number, "nope"); // Error: number