I'm new to Typescript thought I got a hang of it but ran into an issue today of creating an interface for a complex dynamic object from JSON, converted it to generic names for the attributes below.
I'm getting error messages "Source has X element(s) but target allows only 1.". How can I extend my arrays to accept multiple objects, but still retain the attribute names? I have seen indexer solutions but it seems to loose the value of getting an expected JSON object overview.
interface Props {
arrayName: [
{
attributeName: string;
attributeArray: [
{
attributeToken: string;
attributeArray: [
{
attributeName: number;
attributeName: number;
comment: string;
},
];
},
];
attributeArray: [
{
attrbuteName: string;
attributeValue?: number;
attributeLevel: number | null;
attributeMeasurement: number | null;
attributeUnit?: string;
},
];
attributeBoolean: false;
attributeValue: 199.0;
}
];
}