当前,我引入一个名为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}*/);
这种伪注释样式有效吗?
答案 0 :(得分:0)
虽然ESLint不会引发任何警告或问题,但是Closure会发出以下警告:
WARNING - Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?