I want variable temp to be of type Id which is a custom type. However, I am getting error on temp:
Type '{ [index: string]: { [id: string]: { [targets: string]: number; }; }; }' is not assignable to
type 'Id'. 'string' index signatures are incompatible. Type '{ [id: string]: { [targets: string]: number; }; }' (note: the latter type is the type of responseDeploymentData[key][index])
is missing the following properties from type '{ count_targets: number; count_targets_excluded: number; count_targets_pending: number; count_targets_in_progress: number; count_targets_completed: number; count_targets_failed: number; }[]': length, pop, push, concat, and 29 more.
I want to include the count_target info in my type but I am unsure how to incorporate that with the id. See code below.
type Id = {
[key in string]: {
count_targets: number;
count_targets_excluded: number;
count_targets_pending: number;
count_targets_in_progress: number;
count_targets_completed: number;
count_targets_failed: number;
}[];
}
interface CountersData{
//other properties
id?: Id[];
}
\\later in code
const parseCounters = useCallback(
async (
responseDeploymentData: { [state: string]: { [date: string]: {[index: string]: {[id: string] : {[targets: string ]: number} } } } }
) => {
const countersData = {} as CountersData;
for(const index in responseDeploymentData[key][date]){
const temp: Id = responseDeploymentData[key][index];
countersData.id?.push(temp);
}