Initially, one might attempt the following:
interface Port_Mapping {
number: Port_role
}
port_mappings: Port_Mapping[{number: Port_role}] = [];
However, an error is encountered stating:
Type '{ number: Port_role; }' cannot be used as an index type.
Another approach could involve:
interface Port_Mapping {
number: Port_role
}
port_mappings: Port_Mapping[] = [];
this.port_mappings.push({5: Port_role.input})
Yet, this also poses an issue as the 'number' in the interface is considered a name rather than a type, leading to:
Argument of type '{ 5: Port_role; }' is not assignable to parameter of type 'Port_Mapping'. Object literal may only specify known properties, and '5' does not exist in type 'Port_Mapping'.
In my scenario, I aim for a series of dictionaries where each dictionary follows the structure:
[{key1: value1, key2: value2, key3: value3}]