Flow-type For Dynamic Dependencies Of Possible Values Of 'a' Attribute (array) On Values 'b' ([prop: String]: Any)
I have next type definition: type $Schema = { type?: 'object' | 'string' | 'number' | 'array', properties?: { [key: string]: $Schema }, additionalProperties?: boolean, rang
Solution 1:
You can try to use generic + $Keys<...>, like this:
type $Schema<T: {[key: string]: $Schema<*>}> = {
type?: 'object' | 'string' | 'number' | 'array',
properties?: T,
additionalProperties?: boolean,
range?: [number, number],
required?: Array<$Keys<T>>
}
and check schema:
const testSchema: $Schema<*> = {
properties: {
foo: {
type: 'object',
properties: {
bar: {
type: 'string'
}
},
required: ['buz']
}
},
required: ['foo']
}
Post a Comment for "Flow-type For Dynamic Dependencies Of Possible Values Of 'a' Attribute (array) On Values 'b' ([prop: String]: Any)"