I have a JavaScript function getting some parameters including object types. However, one property of a parameter, which is an object, will be used as deprecated. I would like to indicate this situation in the documentation, however I don't know how to use @param tag with @deprecated. Consider the example below:
/**
* This function does something.
*
* @name myFunction
* @function
* @since 3.0
* @param {function} [onSuccess] success callback
* @param {function} [onFailure] failure callback
* @param {object} [options] options for function
* @param {string} [options.lang] display language
* @param {string} [options.type] type of sth
*/
this.myFunction= function (onSuccess, onFailure, options) {
//do something
}
I want to deprecate "type" property of "options" object. How can I do that, or can I?
The require-jsdoc and valid-jsdoc rules will be deprecated. These two rules will remain in ESLint but we will no longer add new features or fix bugs for them. These rules may be removed in a future major release of ESLint.
You can use most JSDoc type syntax and any TypeScript syntax, from the most basic like string to the most advanced, like conditional types.
JSDoc comments are used for documentation lookup with Ctrl+Q in JavaScript and TypeScript, see JavaScript documentation look-up and TypeScript documentation look-up, as well as for type annotations and method return type hints in chained methods.
JsDoc is a great tool for documenting code and providing type-safety in your JavaScript project without any additional configuration. Learn what JsDoc is, how it works, the benefits it provides, and how to use it in your project.
Official JSDoc documentation does not indicate that the @deprecated
tag can be used for deprecating anything else than an entire symbol.
The @deprecated
tag can be used to document that for example a function as a whole has been deprecated.
/** * @deprecated since version 2.0.0 */ function old () { }
You can of course, as @Droogans said in the comments, add something like deprecated:
in front of the @param
description. If a developer somehow still ends up using the deprecated feature, you could implement a warning of some sorts.
/** * @param {string=} bar - Deprecated: description */ function foo (bar) { if (bar) { console.warn('Parameter bar has been deprecated since 2.0.0') } }
A suggestion is using typescript, like so:
function test( options: { /** * @deprecated use newName instead */ name?: string, newName?: string }) { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With