Skip to content

expect ​

Type-focused helper that returns the same Either while keeping strict Left/Right typing.

Interactive example ​

Syntax ​

typescript
function expect<
  GenericEither extends Right | Left
>(
  input: GenericEither
): GenericEither;

Parameters ​

  • input: Either value to preserve.

Return value ​

Returns exactly the same runtime value as input. The function is mainly useful to preserve strict Either typing in composed flows.

See also ​

Released under the MIT license.