Skip to content

nullable ​

Wraps a null or non-null value in an Either, while keeping the information on whether it is filled or empty.

Interactive example ​

Syntax ​

typescript
function nullable<
	const GenericInput extends unknown = null
>(
  input: GenericInput
): GenericInput extends null
  ? NullableEmpty
  : NullableFilled<GenericInput>;

Parameters ​

  • input: Can be null or a concrete value.

Return value ​

  • NullableFilled if the value exists.
  • NullableEmpty if null.

See also ​

Released under the MIT license.