I am trying to document the following object:
let x = {
stopCP: {
enabled: false,
method: "POST",
body: "STOP"
},
startCP: {
enabled: false,
method: "POST",
body: "START"
},
restartCP: {
enabled: false,
method: "POST",
body: "RESTART"
},
viewLog: {
enabled: false,
method: "POST",
body: "VIEWLOG"
}
};
As you can see, the keys of the "child-objects" are all the same. Of course I could document every single property by hand but I was wondering if I could do something like this (aka use some kind of "any-placeholder" like a *
):
/**
* @typedef {Object} options
* @prop {Object} * <--- I want this to apply to stopCP, startCP, restartCP and viewLog all at once
* @prop {Boolean} *.enabled <--- This should target all "enabled" properties of the child objects
* @prop {String} *.method <--- Same for this one
* @prop {String} *.body <--- Also same
*/
Also, how would I specify a set amount of strings? I mean something like this:
/**
* @typedef {Object} options
* @prop {String} *.method ["POST" || "GET" || "PUT"] <---
*/
... which would tell me I can only use POST, GET or PUT as the value of that property.