Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda