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

544
Vistas
Why Object.entries not taking correct types from an object type defined with "Record<>"

Why the type of object key is not properly picked by typescript?

const k: Record<'a' | 'b', number> = { a: 5, b: 6 };

Object.entries(k).forEach(([key, value]) => {
  // key: string
  // value: number
});

I was expecting the types to be

key: 'a' | 'b'
value: number

Because we are saying Record<'a' | 'b', number> and not Record<string, number>.

Also how can I fix this in a safe way with out using any?

playground

There is a possible duplicate here. But that question is not following the minimal-reproducible-example - and hence the answers are too. I felt like that thread is taking too much energy to understand because it is not generalized.

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