Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
Typescript: How to resolve typescript custom type error

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);

    }

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!