PDA

View Full Version : Ext.define and google closure compiler warnings



GangleTron
7 Mar 2013, 10:00 AM
Hi,
I am working on a project that uses google's closure compiler. I really love the ExtJS shorthand style but I am running into too many warnings from the compiler. Here is an example of a component that throws warnings:


my.ErrMsgCmp = Ext.define(null, {
extend : 'Ext.Component',
baseCls: 'form-error',
validText: '',
/**
* Updates the component to contain the error message in the messageArea.
*
* @param {string=} msg The message to set
* @param {boolean=} err (Optional) Whether the message is an error or not. Default: false
*/
setMessage: function(msg, err){
var me = this,
baseCls = me.baseCls;
// Update style class and tooltip content
if (err === true) {
me.addCls(baseCls + '-invalid');
me.removeCls(baseCls + '-valid');
me.update(msg);
} else {
me.addCls(baseCls + '-valid');
me.removeCls(baseCls + '-invalid');
me.update(msg||me.validText);
}
}
});

This throws a warning at compile:


my/controllers/FileImport.js:71: WARNING - Property setMessage never defined on my.ErrMsgCmp
if (errText) messageBox.setMessage(errText, true);
^


Popping out the setMessage method into a prototype works but then the other custom parameters (baseCls and validText) get caught. The compiler doesn't know that the obj passed into Ext.define gives the properties to the class.

Has anyone run into this and figured out how to handle this without pulling all the custom parameters and methods out into a prototype function? I tried the @lends tag but couldn't get it to work.

Thanks!