I am having a function that accepts one string parameter. This parameter can have only one of a few defined possible values. What is the best way to document the same? Shoul
I don't think there's a formal way of writing allowed values in JSDoc.
You certainly can write something like @param {String('up'|'down'|'left'|'right')}
like user b12toaster mentioned.
But, by taking reference from APIDocjs, here's what I use for writing constrained values, aka allowedValues.
/**
* Set the arrow position of the tooltip
* @param {String='up','down','left','right'} position pointer position
*/
setPosition(position='left'){
// YOUR OWN CODE
}
Oh yeah, I'm using ES6.