This doesn't work but I want to do something like this:
type ProxyNestedKeys<O> = {
[P in Extract<keyof O, string> Q in Extract<keyof O[P], string>]: boolean
}
so that ProxyNestedKeys can be indexed by nested properties of O.
For example if I was building a validation library that did the following:
const schema = {
foo: {
minVal: 2,
maxVal: 5
}
}
const state = { foo: 6 }
const result = validate(schema, state)
// result
{
foo: {
$isValid: false
$validations: {
minVal: true
maxVal: false
}
}
}
So the result is what I'm trying to type and I've got it this far:
// S is the state and V is the schema
type Validation<S, V> = {
[K in Extract<keyof S, keyof V>]: Validation<S[K], V[K]>
} & {
$isValid: boolean
$validations: what goes here?
}
I don't need to recursively get all props just one more level deep.