“WARNING – SuspicIoUs code. The result of the ‘getprop’ operator is not being used.”
当我使用闭包编译器时,我在JavaScript代码中看到了两行代码.它们是不报告问题的其他typedef中的typedef.我应该寻找什么?
编辑
受影响的代码:
/** * @typedef {{playerId: number,playerName: string,basescores: Array.<number>,bonusscores: Array.<number>,* teamscoreAdjustments: Array.<number>}} */ wias.GaMetableTeamMember; /** * @typedef {{id: number,teamMembers: Array<wias.GaMetableTeamMember>,teamName: string}} */ wias.GaMetableTeam; /** * @typedef {{id: number,availableRound: boolean,bonusScoring: boolean,complete: boolean,gameLength: number,* gameType: string,lastPlayed: string,numberOfRounds: number,teams: Array.<wias.GaMetableTeam>,winners: * Array.<string>}} */ wias.GaMetable;
警告:
wias.js:77: WARNING - SuspicIoUs code. The result of the 'getprop' operator is not being used. wias.GaMetableTeam; ^
为什么要警告而不是其他地方?
解决方法
这意味着您拥有无效的代码.
Typedef(或记录类型)对于编译器指向问题所在的确切位置更为棘手,但在某处您获得的值未被使用.
一些关于类型系统的阅读以及最适合编译器的内容
https://docs.google.com/document/d/1Uq_vNyPZjlRvYZJclX6N37Fjsiah4XNciEPSBfFiREs/edit
并简单地重新创建警告
if (true) { //have nothing in here }