Closed cpiber closed 2 years ago
Good catch. Would you be interested in doing a pull request to fix it?
Sure, give me a bit of time though please
So, I just got to it and I have a problem: Ideally ReusableValidator<T>
would also assert value is T
, however typescript complains Assertions require every name in the call target to be declared with an explicit type annotation.
. Do you happen to have a solution for that? I don't think it's elegant to have to explicitly them, and it's a breaking change...
Maybe one option would be not to include assert, but introduce a convenience type that extracts the type of ReusableValidator
and provides another type that actually asserts. That way we don't have a breaking change but also a way for the user to easily get the assertion.
isValid
always assumes the type of the value, because the first argument should beunknown
(like it is forow
itself): https://github.com/sindresorhus/ow/blob/3728d9119a19e1a95cb58bebe602afd308c40630/source/index.ts#L39Looking over the rest of the file, it seems this mistake was made in several places;
ReusableValidator
should probably also not useT
for the value (and assert?)