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

193
Vistas
Typing a string index

I have some data.

const people = {
    john : {
     //somedata
    },
   peter : {
     //somedata
    },
   mark: {
     //somedata
    }
}

and I type it

  export type People = {
     [key : string]: Person
   }


 export interface Person {
   age: number;
   profession: string;
 // some more data

   }

The error is TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type. I would not usually use a string as the key but in this case it is necessary and typescript does not like it even though I have told it to expect a string.

Any idea how I can type this properly?

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