"Property never defined" warning when compiling subset of code

283 views
Skip to first unread message

Steve

unread,
Dec 9, 2013, 10:38:46 AM12/9/13
to closure-comp...@googlegroups.com

I have a large JS application with which I use Closure.  I also use the PrototypeJS library, so for my
compilation I have a custom externs.js file, select externs from the Closure sources, and the
--use_only_custom_externs option.  Also using advanced optimizations.

The first JS file in my application is "base.js" which contains some utilities used throughout the
application.  Currently I'm attempting to compile just the "base.js" and another file for use elsewhere on the
site, and Closure is throwing "Property xxx never defined on yyy" warnings that I don't see when compiling the
entire application.  I'm including the same externs.

It does this with v20130823 and v20131118 but not v20121212.  (This is not an exhaustive bisect, just the
versions I happen to have on hand.)

Why would I get different warnings when compiling a subset of a larger application?

The warning:

base.js:510: WARNING - Property onFailure never defined on Ajax.Base.prototype.options
(request.options.onTimeout || request.options.onFailure || Prototype.emptyFunction)(response, response.headerJSON);

Relevant lines from externs.js:

var Ajax = {};
/** @constructor */
Ajax.Base = function(){};
/** @type {Object} */
Ajax.Base.prototype.options;
/** @type {function(Ajax.Response, Object)|undefined} */
Ajax.Base.prototype.options.onFailure;

(Incidentally, I don't use Ajax in the two-file subset I'm attempting to compile.)

Dimitris Vardoulakis

unread,
Dec 9, 2013, 2:28:50 PM12/9/13
to closure-comp...@googlegroups.com
I just filed

Thanks for the report. For now, you can rewrite your externs slightly to sidestep the issue. (See the workaround in the bug report.)

Steve

unread,
Dec 10, 2013, 10:32:09 AM12/10/13
to closure-comp...@googlegroups.com

Thanks, Dimitris.  The record type workaround works for me, although it's not as flexible as the @type annotation.

Chad Killingsworth

unread,
Dec 10, 2013, 10:40:01 AM12/10/13
to closure-comp...@googlegroups.com
Often in this case we either use private constructors or interfaces for these cases. Not as convenient, but it get's the job done. Here's an example from the Google Feed API extern: https://code.google.com/p/closure-compiler/source/browse/contrib/externs/google_feed_api.js#94

Chad Killingsworth
Reply all
Reply to author
Forward
0 new messages