-
Hello! What is the correct or clean way to document jQuery event handlers and functions with JSDoc? Currently, I’m documenting them like this /**
* @see {@link https://api.jquery.com/submit/#on1}
* @external jQuery
* @param {string} event
* @param {callback} event
* @description Some text...
*/
$("form").on("submit", function () {
// do something....
}) Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
JS Doc has various variants so it depends what's the purpose of this documentation. For example, TypeScript supports the If you use TypeScript as a language and just want to use JSDoc for documentation, you can define multiple signature types and a proper JS Doc comment above them, as is done e.g. in DefinitelyTyped; see the |
Beta Was this translation helpful? Give feedback.
JS Doc has various variants so it depends what's the purpose of this documentation. For example, TypeScript supports the
@overload
tags for multiple signatures: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#overload-support-in-jsdoc.If you use TypeScript as a language and just want to use JSDoc for documentation, you can define multiple signature types and a proper JS Doc comment above them, as is done e.g. in DefinitelyTyped; see the
.on()
method: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/108e356f1a990ac7a2416a9790ff8bdcd4919d30/types/jquery/JQuery.d.ts#L7875-L8371.