在函数的参数中使用jsdoc inline

问题描述 投票:1回答:1

目前我引入了一个名为data的参数,所以我可以给它一个类型:

/**
 * @type {HomeOverview} data
 */
const data =  { id: homeId, name: home.name, notificationCnt };
sails.sockets.broadcast(userId, 'joined_home', data);

但是我理想的只是想像这个伪注释一样传递这个内联:

sails.sockets.broadcast(userId, 'joined_home', { id: homeId, name: home.name, notificationCnt }/*@type {HomeOverview}*/);

这种伪评论风格有效吗?

jsdoc
1个回答
0
投票

虽然ESLint不会发出任何警告或问题,但Closure会发出警告:

 WARNING - Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
© www.soinside.com 2019 - 2024. All rights reserved.