Open sounisi5011 opened 3 years ago
I have added something to help with this in #224. The problem why we can't simply write asserts value is T
instead of void
here is the same why the following exists:
https://github.com/sindresorhus/ow/blob/3384c4eb1b9093a5efc0ea8ad7077e0e4a21f3b8/source/index.ts#L122-L125
Currently,
ow()
funciton is of type Assertion Functions.https://github.com/sindresorhus/ow/blob/f26115d48523933f061526b44eb421db322556db/source/index.ts#L31-L46
However, the
ReusableValidator
returned byow.create()
is not an Assertion Functions type.ReusableValidator
returns avoid
type! In addition, the value argument does not seem to be of typeunknown
...https://github.com/sindresorhus/ow/blob/f26115d48523933f061526b44eb421db322556db/source/index.ts#L53-L60
For this reason, using
ow.create()
in TypeScript does not provide proper type validation.