Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!