Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda