1

如果在构造函数中使用类属性而没有隐式定义,有什么方法可以发出警告?像这样:

define(["dojo/_base/declare"],
    function (declare) {
        return declare("MyClass", [], {

            /**
             * @constructor
             */
            constructor: function () {
                /**
                 * @type {number}
                 * @private
                 */
                this.a = 1;
            },

            doSomething: function () {
                this.a = 2; //Ok
                this.b = 3; //Want warning here, if b is not defined in constructor
            }

        });
    });

我用 JS+Dojo+JSDoc+Webstorm

4

0 回答 0