Array.prototype.indexOf
古い IE バージョン用に再定義しようとしています。Google Closure Compiler によると正しく入力できません。
の型@this
が間違っていると言われています。
if (!Array.prototype.indexOf) {
/**
* @this {Array}
* @param {*} item
* @param {number=} from: ignored
* @return {number}
*/
Array.prototype.indexOf = function(item, from) {
// ...
}
}
次の出力が得られます
test.js:12: WARNING - variable Array.prototype.indexOf redefined with type \
function (this:Array, *, number=): number, original definition at \
externs.zip//es3.js:633 with type function (this:Object, *, number=): number
Array.prototype.indexOf = function(item, from) {
^
驚くべきことに、by を変更@this {Array}
すると@this {Object}
(あまり意味はありませんが)、次のさらにあいまいなメッセージが返されます。
test.js:12: WARNING - variable Array.prototype.indexOf redefined with type \
function (this:Object, *, number=): number, original definition at \
externs.zip//es3.js:633 with type function (this:Object, *, number=): number
Array.prototype.indexOf = function(item, from) {
^
適切に行う方法に関するヒントはありますか?