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 :\