Go to repository

Function asDefined

Returns a typed defined version of the given value.

Given a value that may be undefined to the typechecker, but, you are sure that in runtime it would never be so, as per your preconditions, this function returns a typed defined version of the value.

This is just an identity function, where the value is return as-is. This function only exist as to pass the static typechecking system in some particular scenarios, to avoid casting in multiple places.

Type Parameters

  • T

Parameters

  • x: T

    The value to return.

Returns T

The given value.