Target function to assert
Optional
errorFactory: ((props: TypeGuardError.IProps) => Error)Custom error factory. Default is TypeGuardError
The wrapper function with type assertions
A TypeGuardError or a custom error generated by errorFactory
Jeongho Nam - https://github.com/samchon
Asserts return value with strict equality.
Asserts a function, by wrapping the function and checking its return value through assertEquals function. If the return value does not match the expected type, it throws an TypeGuardError or a custom error generated by the errorFactory parameter.
For reference, TypeGuardError.path would be a little bit different with individual assertEquals function. If the TypeGuardError occurs from the return value, the path would start from
$input.return
.By the way, if what you want is not just finding the 1st type error through assertion, but also finding every type errors, then use validateEqualsReturn instead. Otherwise, what you want is not only asserting return value, but also asserting parameters, you can use assertEqualsFunction instead.
On the other hand, if you want to allow any superfluous properties, utilize assertReturn or validateReturn instead.