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

460
Visualizações
Mongoose 6 $group with Typescript -> Property '_id' is incompatible with index signature

I am migrating from js to ts and also from mongoose 5.8 to 6.1 The following code was working fine earlier

let getActionsTakenByApp = (store_url: string) => {
    return AppAction.aggregate([
        {
            $match: { store_url }
        },
        {
            $group: {
                _id: {
                    'action_type': '$action_type'
                },
                count: {
                    $sum: 1
                }
            }
        }
    ]);
}

But now typescript is now showing this error.

Type '{ _id: { action_type: string; }; count: { $sum: number; }; }' is not assignable to type '{ [key: string]: { $count?: any; $accumulator?: any; $addToSet?: any; $avg?: any; $first?: any; $last?: any; $max?: any; $mergeObjects?: any; $min?: any; $push?: any; $stdDevPop?: any; $stdDevSamp?: any; $sum?: any; }; _id: any; }'.   Property '_id' is incompatible with index signature.
    Type '{ action_type: string; }' is not assignable to type '{ $count?: any; $accumulator?: any; $addToSet?: any; $avg?: any; $first?: any; $last?: any; $max?: any; $mergeObjects?: any; $min?: any; $push?: any; $stdDevPop?: any; $stdDevSamp?: any; $sum?: any; }'.
      Object literal may only specify known properties, and ''action_type'' does not exist in type '{ $count?: any; $accumulator?: any; $addToSet?: any; $avg?: any; $first?: any; $last?: any; $max?: any; $mergeObjects?: any; $min?: any; $push?: any; $stdDevPop?: any; $stdDevSamp?: any; $sum?: any; }'.ts(2322)

I'm still new to typescript and trying to figure out what's the issue. Any help would be appreciated! Thank you!!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It's a bug introduced in 6.1.0

It will be fixed once related PR is merged and released.

In the meantime, you can downgrade to a lower version.

over 4 years ago · Santiago Trujillo Relatório
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