sindresorhus / ow

Function argument validation for humans
https://sindresorhus.com/ow/
MIT License
3.8k stars 105 forks source link

Allow potentially undefined functions to be checked #184

Closed TheGuardianWolf closed 3 years ago

TheGuardianWolf commented 4 years ago

proposed changes to fix #147


IssueHunt Summary ### Referenced issues This pull request has been submitted to: - [#147: TypeScript optional function argument throws error TS2345 with `ow.optional.function`](https://issuehunt.io/repos/105227249/issues/147) ---
sindresorhus commented 4 years ago

Can you add some tests?

TheGuardianWolf commented 4 years ago

Sure, I will do that

TheGuardianWolf commented 4 years ago

I've put a few tests for the optional function check

ow((() => {}) as any as ((() => void) | undefined), ow.optional.function);

This case originally triggered a TS error, but doesn't on my branch, do you have any additional tests in mind?

TheGuardianWolf commented 3 years ago

Finally took care of it