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

199
Vistas
Typescript: type is object where property names are unknown

I am currently making a component in React and one of the properties is called 'initNavData'. This is an object where the property names will always be different names and there are an unknown amount of these properties. Each of them will have the same structure though. How can I create a type for this?

I saw the [x: string] suggestion, but will this allow for an unlimited amount of properties?

interface WizardProps {
  id: string;
  // parentWizard: string
  isSubwizard: boolean;
  wizardName: string;
  initNavData: {
    [x: string]: {
      label: string;
      status: string;
      current: boolean;
      active: boolean;
      icon: string;
      key: string;
    }
  }
}
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

yeah, you can use index signatures. As TypeScript handbook says:

Sometimes you don’t know all the names of a type’s properties ahead of time, but you do know the shape of the values.

In those cases you can use an index signature to describe the types of possible values

about 4 years ago · Santiago Gelvez Denunciar
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