I am trying to write a function in typescript which validates that an object has certain properties and I got stuck at the very beginning do keys xyz exist? I tried to do that with the following code:
import _ from 'lodash/fp';
type Pred = (o: Object) => boolean
const required_keys: Pred[] = _.map(_.has,['id','field1'])
const validate: (o: Object) => boolean = _.overEvery(required_keys)
I expected that type of required_keys
would be Pred[]
but typescript LSP tells me it is boolean[]
. I expected that after we apply one argument to _.has
I still have to apply another one the object that that is being tested.
Am I wrong or is it LSP, and how can LSP and I come to an agreement?