简体   繁体   中英

JSDoc for Lambda function in object

I need to use JSDoc to make sock , data variables known

var exec = {
    /**
     * @param {Number} sock
     * @param {String} data
     */
    1: (sock, data) => {
        console.log("GG");
    },
    2: (sock, data) => {

    },
    3: (sock, data) => {

    }
};

let's say sock is Number , and data is String .

/**
 * @param {Number} sock
 * @param {String} data
 */

I need to set the JSDoc one time only, for the whole object.

/**
 * @type {Object.<number, function(Object, Object):void>}
 */
var exec = {
    1: (sock, data) => {
        console.log("GG");
    },
    2: (sock, data) => {

    },
    3: (sock, data) => {

    }
};

This defines an object with numbers as keys and functions as values which takes two params of type Object.

The Syntax compiles from

Object.<[keyType, valueType]>

and

function(param1Type, param2Type, ...):returnType

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM