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

148
Vistas
In JSDoc, how to apply param type as bunch of strings from a constant array of objects string property?

Let's say I have an object like this;

const typesOfIceCreams = [
 {id: "CHOCOLATE", price: 0.49, rating: 4.5},
 {id: "CHERRY", price: 0.54, rating: 4.3},
 {id: "LEMON", price: 0.44, rating: 4.6},
]

I want to get an object from typesOfIceCreams array by id property. So I have a function like this;

/**
* @param {?} iceCreamId
*/
const getIceCreamById = (iceCreamId) => {
 return typesOfIceCreams.find(iceCream => iceCream.id === iceCreamId);
}

* @params { "CHOCOLATE" | "CHERRY" | "LEMON" } iceCreamId

I could have written like this. But it is time consuming whenever I want to add an new ice cream data to array. I would like something similar to this;

* @params { typesOfIceCreams.map(iceCream => iceCream.id) }

Thus, I will be able to see that three options ("CHOCOLATE" | "CHERRY" | "LEMON") whenever I try to call getIceCreamById() function.

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