At this moment Success::flatMap and Failure::recoverWith functions use function restrictCallableReturnType to check whether callable passed as argument has defined return type to TryCatch. It rises TypeError in case when return type is not defined or it is different than expected.
The proposal is to add checks enforcing also callable arguments types, ie example check input argument of callable passed to TryCatch::map or TryCatch::filter or similar functions. Type checks could be also used for checking consistency of functions passed to methods like TryCatch::transform.
Instead of using functions that throws TypeError directly we can introduce checkers returning boolean type and use them in combination with assert.
At this moment
Success::flatMap
andFailure::recoverWith
functions use functionrestrictCallableReturnType
to check whether callable passed as argument has defined return type toTryCatch
. It risesTypeError
in case when return type is not defined or it is different than expected.The proposal is to add checks enforcing also callable arguments types, ie example check input argument of callable passed to
TryCatch::map
orTryCatch::filter
or similar functions. Type checks could be also used for checking consistency of functions passed to methods likeTryCatch::transform
.Instead of using functions that throws
TypeError
directly we can introduce checkers returningboolean
type and use them in combination withassert
.