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

179
Views
JSdoc: nombre de clave dinámica del objeto de retorno
/** * * @param {string} key * @param {any} value * @returns {{[key]: typeof value}} */ const set = (key, value) => { return {[key]: value} } const myObj = set("country", "USA") myObj. // should suggest .country key

No puedo entender cómo definir correctamente el nombre clave del objeto de retorno

ingrese la descripción de la imagen aquí

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Lo siguiente haría el truco. Simplemente use @template para escribirlo como una función genérica.

 /** * @template {string} K * @template T * @param {K} key * @param {T} value * @returns {Record<K, T>} */ const set = (key, value) => { return {[key]: value} }

Captura de pantalla

about 4 years ago · Santiago Trujillo Report
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!