最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What does "WARNING - Suspicious code. The result of the 'getprop' operator is not being us

programmeradmin2浏览0评论

"WARNING - Suspicious code. The result of the 'getprop' operator is not being used."

I'm seeing this for two lines in my JavaScript code when I use the closure piler. They are typedefs in among other typedefs that don't report issues. What should I be looking for?

EDIT

Affected code:

/**
 * @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, plete: boolean, gameLength: number,
 *          gameType: string, lastPlayed: string, numberOfRounds: number, teams: Array.<wias.GameTableTeam>, winners:
 *          Array.<string>}}
 */
wias.GameTable;

Warning:

wias.js:77: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
wias.GameTableTeam;
^

Why a warning there and not elsewhere?

"WARNING - Suspicious code. The result of the 'getprop' operator is not being used."

I'm seeing this for two lines in my JavaScript code when I use the closure piler. They are typedefs in among other typedefs that don't report issues. What should I be looking for?

EDIT

Affected code:

/**
 * @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, plete: boolean, gameLength: number,
 *          gameType: string, lastPlayed: string, numberOfRounds: number, teams: Array.<wias.GameTableTeam>, winners:
 *          Array.<string>}}
 */
wias.GameTable;

Warning:

wias.js:77: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
wias.GameTableTeam;
^

Why a warning there and not elsewhere?

Share Improve this question edited Feb 3, 2012 at 6:53 Ben Flynn asked Feb 3, 2012 at 6:13 Ben FlynnBen Flynn 18.9k21 gold badges101 silver badges144 bronze badges 1
  • I'm not sure what the warning means, but I'm curious to see the actual code it is talking about... – nnnnnn Commented Feb 3, 2012 at 6:32
Add a ment  | 

1 Answer 1

Reset to default 6

It means that you have code which does nothing.

Typedef's (or record types) are more tricky for the piler to point to the exact spot where the issue is, but somewhere you are getting a value which is not being used.

some reading about the type system and what works best with the piler https://docs.google./document/d/1Uq_vNyPZjlRvYZJclX6N37Fjsiah4XNciEPSBfFiREs/edit

and to recreate the warning simply

if (true) {
   //have nothing in here
}
发布评论

评论列表(0)

  1. 暂无评论