sindresorhus / ow

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

Static type error for `ow.object.valuesOfType()` #181

Closed rauschma closed 3 years ago

rauschma commented 4 years ago

The following doesn’t seem to work for me:

const pred = ow.object.valuesOfType(ow.any(ow.string, ow.boolean));
// Argument of type 'AnyPredicate<string | boolean>' is not assignable to parameter of type 'Predicate<unknown>'.
sindresorhus commented 4 years ago

I think we need to do the same as https://github.com/sindresorhus/ow/commit/ec59a5c59664d253854ff06d66c8d66ec4336cef here too.

ilkerceng commented 4 years ago

hi @rauschma, i couldn't generate the error, i have just tested it with:

const bug = input => {
    ow(input, ow.object.valuesOfType(ow.any(ow.string, ow.boolean)));
};

bug({
    a: true,
    b: "test",
});

it doesn't give me any error. Am i missing something?

rauschma commented 4 years ago

@ilkerceng Did you try the exact line I mentioned? I got a static error when I last used it.

That’s the only information I have, sorry!

ilkerceng commented 4 years ago

@rauschma Yep. I have just tried it the line your mentioned with ow@0.17.0. And it doesn't give any error.

rauschma commented 4 years ago

OK, then I must have done something wrong. Thanks for checking, sorry for the noise!

ilkerceng commented 4 years ago

Thanks.

ilkerceng commented 4 years ago

hi @rauschma, i am really sorry, i have just came up with the same error now. it was my fault.