type ParameterInfo = {
required?: true;
pattern?: RegExp;
// other known keys
[otherKeys: string]: ParameterInfo;
}
So I can have a ParameterInfo
with 0-many nested ParameterInfo
s under it, e.g.:
{
user: { // this is a ParameterInfo
required: true,
username: { // I'm a ParameterInfo, too
required: true,
pattern: /.../,
},
password: { // I'm a ParameterInfo, too
required: true,
},
},
}
Using the type definition at the top, all of the known keys (e.g. required
, pattern
) are highlighted with the error:
Property 'required' of type 'true' is not assignable to string index type 'ParameterInfo'. ts(2411)