Определите параметры в JSDoc для встроенных анонимных функций.

Если я определяю функцию как переменный объект, тогда PhpStorm покажет автозаполнение для параметра item.

        /**
         * @param {Rules.FolderGroupItem} item
         **/
        var forEach = function(item) {
            if(item.type == 'label')
            {
                str += this.renderLabel(item.paramType);
            }
            if(item.type == 'input')
            {
                str += this.renderInput(item.paramType);
            }
        };
        _.each(items,forEach,this);

Если я напишу то же самое в качестве встроенного параметра для функции _.each(). Тогда это не работает.

        _.each(items,forEach,
            /**
             * @param {Rules.FolderGroupItem} item
             **/
            function(item) 
        {
            if(item.type == 'label')
            {
                str += this.renderLabel(item.paramType);
            }
            if(item.type == 'input')
            {
                str += this.renderInput(item.paramType);
            }
        });

person Reactgular    schedule 13.04.2013    source источник


Ответы (1)


Я нашел ответ. Вот.

    _.each(items,forEach,function(/*Rules.FolderGroupItem*/item) 
    {
        if(item.type == 'label')
        {
            str += this.renderLabel(item.paramType);
        }
        if(item.type == 'input')
        {
            str += this.renderInput(item.paramType);
        }
    });
person Reactgular    schedule 13.04.2013
comment
Где в документах вы это нашли? Мой редактор, кажется, не понимает этого. - person ᆼᆺᆼ; 07.02.2018