I've just started learning JSDoc
and the first stumbling block I've come across is how to indicate a function parameter which must be valid JSON
.
I'm looking at the documentation for @param
and I can't see:
@param {JSON}
What's the correct approach in JSDoc
to indicate a function parameter which must be valid JSON
?
(Surely it's not right to use @param {string}
, is it?)
In the absence of any other answers so far, I'm going to go with defining JSON
as a type at the top of the javascript file, like this:
/**
* Define JSON
* @typedef {string} JSON
*/
and then, later on, use the JSON
type in my function definitions etc.
See the line starting with @param
below:
/**
* Compresses JSON data
* @function compressJSON
* @param {JSON} myJSON - any valid JSON
* @returns {string} a compressed version of the JSON input
*/
Further Reading: