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

266
Views
JSDoc: how to define a type that's equal to object's property names- like Typescript's keyof?

I'm looking for a way to get an object's property names as a type using JSDoc.

Let there be a typedef of an object named Record

/**
 * @typedef {{
      date: string,
      a1: string,
      a2: string,
   }} Record
 */

I want the variable fields to be documented as equal to the object's properties- which means for this example: 'date' | 'a1' | 'a2'

/**
 * @type {*keyof Record??*} in this case, this will be equal to @type {'date' | 'a1' | 'a2'}
 */
let fields = 'a1';

Typescript provides the keyof keyword, which does just that. unfortunately, the system I'm working on does not support typescript :\

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!