0

I wrote some javascript code relying on Prototype.js.

Prototype.js's way to define classes is the following:

var Person = Class.create({
  initialize: function(name) {
    this.name = name;
  },
  say: function(message) {
    return this.name + ': ' + message;
  }
});

All the keys passed to Class.create will be added to Person.prototype. With this mechanism Prototype.js is able to offer inheritance. [link]


Closure compiler now complains because it thinks that those initialize and say functions are "neither a prototype method nor marked as a constructor". [link, check: JCS_UNSAFE_THIS]

Is there any way to fix this?

4

1 に答える 1

1

完全に重複した質問ではありませんが、答えは次のとおりです。

google-closure-compiler の名前空間の平坦化に対応するために javascript を再フォーマットするための John の回答を参照してください

于 2013-08-30T19:36:22.367 に答える