我不能得到正確鍵入下面的代碼:正確地關閉編譯器類型的實例變量
/**
* @constructor
*/
function F() {
this.a = 0;
};
/**
* @type {function(number)}
*/
F.prototype.g = function(b) {
this.a += b;
};
我得到以下警告:
test.js:12: WARNING - could not determine the type of this expression
this.a += b;
^
我怎樣才能正確地輸入這個this
例?
- 編輯 -
如果你想看到警告時,您需要設置reportUnknownTypes
到true
的解釋here。我試圖獲得100%的類型代碼,我想我無法達到那個簡單的程序。
太棒了,現在很有意義。 –