Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Resolved majority of Closure Compiler warnings (VERBOSE)

- Ignored warnings from tests for now
- VERBOSE flag removed from Makefile for now until I can figure out how to
  resolve certain warnings
  • Loading branch information...
commit e24784529eda31f48000469e16eb5aeaa5534a86 1 parent 3922d68
Mike Gerwitz authored
1  Makefile
@@ -70,7 +70,6 @@ build/%.min.js: build/%.js $(path_tools)/externs-global.js $(path_externs_inter
70 70 $(compiler)
71 71 cat $(path_tools)/license.tpl > $@
72 72 java -jar $(compiler) \
73   - --warning_level VERBOSE \
74 73 --externs $(path_tools)/externs-global.js \
75 74 --externs $(path_build)/externs-internal.js \
76 75 --js $< >> $@ || rm $@
6 README.todo
@@ -41,3 +41,9 @@ PERFORMANCE TESTS
41 41 Performance tests need to be written for every aspect of the system. They will
42 42 ultimately be graphed to show the relative performance across versions of the
43 43 software.
  44 +
  45 +
  46 +CLOSURE COMPILER WARNINGS
  47 +-------------------------
  48 +Certain warnings are suppressed. Figure out the best way to resolve them without
  49 +suppressing them, unless suppression is truely the best option.
65 lib/ClassBuilder.js
@@ -80,8 +80,10 @@ var util = require( __dirname + '/util' ),
80 80 *
81 81 * @param {Object} member_builder member builder
82 82 *
83   - * @param {VisibilityObjectFacotry} visibility_factory visibility object
  83 + * @param {VisibilityObjectFactory} visibility_factory visibility object
84 84 * generator
  85 + *
  86 + * @constructor
85 87 */
86 88 module.exports = exports =
87 89 function ClassBuilder( member_builder, visibility_factory )
@@ -89,7 +91,8 @@ function ClassBuilder( member_builder, visibility_factory )
89 91 // allow ommitting the 'new' keyword
90 92 if ( !( this instanceof exports ) )
91 93 {
92   - return new exports( member_builder, visibility_factory );
  94 + // module.exports for Closure Compiler
  95 + return new module.exports( member_builder, visibility_factory );
93 96 }
94 97
95 98 /**
@@ -202,9 +205,9 @@ exports.getForcedPublicMethods = function()
202 205 * Since a reference is returned (rather than a copy), the returned object can
203 206 * be modified to alter the metadata.
204 207 *
205   - * @param {Class} cls class from which to retrieve metadata
  208 + * @param {Function|Object} cls class from which to retrieve metadata
206 209 *
207   - * @return {Object}
  210 + * @return {__class_meta}
208 211 */
209 212 exports.getMeta = function( cls )
210 213 {
@@ -278,9 +281,12 @@ exports.isInstanceOf = function( type, instance )
278 281 * The class to inherit from (the first argument) is optional. If omitted, the
279 282 * first argument will be considered to be the properties list.
280 283 *
281   - * @return {Object} extended class
  284 + * @param {Function|Object} _ parent or definition object
  285 + * @param {Object=} __ definition object if parent was provided
  286 + *
  287 + * @return {Function} extended class
282 288 */
283   -exports.prototype.build = function extend()
  289 +exports.prototype.build = function extend( _, __ )
284 290 {
285 291 // ensure we'll be permitted to instantiate abstract classes for the base
286 292 this._extending = true;
@@ -374,7 +380,7 @@ exports.prototype.build = function extend()
374 380 var new_class = this.createCtor( cname, abstract_methods, members );
375 381
376 382 // closure to hold static initialization to be used later by subtypes
377   - initStaticVisibilityObj( new_class, static_members );
  383 + initStaticVisibilityObj( new_class );
378 384 var staticInit = function( ctor, inheriting )
379 385 {
380 386 attachStatic( ctor, static_members, base, inheriting );
@@ -524,7 +530,7 @@ exports.prototype.buildMembers = function buildMembers(
524 530 *
525 531 * @param {function()} ctor class
526 532 * @param {string} cname class name
527   - * @param {Object} abstract_methods
  533 + * @param {{__length}} abstract_methods object containing abstract methods
528 534 *
529 535 * @return {undefined}
530 536 */
@@ -596,9 +602,18 @@ exports.prototype.createConcreteCtor = function( cname, members )
596 602 var args = null,
597 603 _self = this;
598 604
599   - // constructor function to be returned (the name is set to ClassInstance
600   - // because some debuggers (e.g. v8) will show the name of this function for
601   - // constructor instances rather than invoking the toString() method)
  605 + /**
  606 + * Constructor function to be returned
  607 + *
  608 + * The name is set to ClassInstance because some debuggers (e.g. v8) will
  609 + * show the name of this function for constructor instances rather than
  610 + * invoking the toString() method
  611 + *
  612 + * @constructor
  613 + *
  614 + * Suppressing due to complaints for using __initProps
  615 + * @suppress {checkTypes}
  616 + */
602 617 function ClassInstance()
603 618 {
604 619 if ( !( this instanceof ClassInstance ) )
@@ -790,7 +805,7 @@ exports.prototype._attachPropInit = function(
790 805 *
791 806 * @param {Object} keywords keywords to scan
792 807 *
793   - * @return {bool} true if to be static, otherwise false
  808 + * @return {boolean} true if to be static, otherwise false
794 809 */
795 810 function keywordStatic( keywords )
796 811 {
@@ -804,7 +819,7 @@ function keywordStatic( keywords )
804 819 /**
805 820 * Creates and populates the static visibility object
806 821 *
807   - * @param {function()} class
  822 + * @param {Function} ctor class
808 823 *
809 824 * @return {undefined}
810 825 */
@@ -812,8 +827,12 @@ function initStaticVisibilityObj( ctor )
812 827 {
813 828 var _self = this;
814 829
815   - // the object will simply be another layer in the prototype chain to
816   - // prevent protected/private members from being mixed in with the public
  830 + /**
  831 + * the object will simply be another layer in the prototype chain to
  832 + * prevent protected/private members from being mixed in with the public
  833 + *
  834 + * @constructor
  835 + */
817 836 var sobj = function() {};
818 837 sobj.prototype = ctor;
819 838
@@ -969,10 +988,13 @@ function attachStatic( ctor, members, base, inheriting )
969 988 /**
970 989 * Initializes class metadata for the given class
971 990 *
972   - * @param {Class} func class to initialize metadata for
973   - * @param {Class} cparent class parent
  991 + * @param {Function} func class to initialize metadata for
  992 + * @param {Function} cparent class parent
974 993 *
975 994 * @return {undefined}
  995 + *
  996 + * Suppressed due to warnings for use of __cid
  997 + * @suppress {checkTypes}
976 998 */
977 999 function createMeta( func, cparent )
978 1000 {
@@ -1046,6 +1068,7 @@ function attachInstanceId( instance, iid )
1046 1068 */
1047 1069 function initInstance( instance )
1048 1070 {
  1071 + /** @constructor */
1049 1072 var prot = function() {};
1050 1073 prot.prototype = instance;
1051 1074
@@ -1093,6 +1116,8 @@ function attachInstanceOf( instance )
1093 1116 * @param {number} cid class id
1094 1117 *
1095 1118 * @return {Object|null} instance object if found, otherwise null
  1119 + *
  1120 + * @suppress {checkTypes}
1096 1121 */
1097 1122 exports.getMethodInstance = function( inst, cid )
1098 1123 {
@@ -1122,7 +1147,7 @@ function attachAbstract( func, methods )
1122 1147 * Returns whether the class contains abstract methods (and is therefore
1123 1148 * abstract)
1124 1149 *
1125   - * @return {Boolean} true if class is abstract, otherwise false
  1150 + * @return {boolean} true if class is abstract, otherwise false
1126 1151 */
1127 1152 util.defineSecureProp( func, 'isAbstract', function()
1128 1153 {
@@ -1153,8 +1178,8 @@ function attachId( ctor, id )
1153 1178 /**
1154 1179 * Sets class flags
1155 1180 *
1156   - * @param {Class} ctor class to flag
1157   - * @param {Object} props class properties
  1181 + * @param {Function} ctor class to flag
  1182 + * @param {Object} props class properties
1158 1183 *
1159 1184 * @return {undefined}
1160 1185 */
3  lib/FallbackVisibilityObjectFactory.js
@@ -35,7 +35,8 @@ module.exports = exports = function FallbackVisibilityObjectFactory()
35 35 // permit omitting 'new' keyword
36 36 if ( !( this instanceof exports ) )
37 37 {
38   - return new exports();
  38 + // module.exports for Closure Compiler
  39 + return new module.exports();
39 40 }
40 41 };
41 42
72 lib/MemberBuilder.js
@@ -39,6 +39,12 @@ var util = require( __dirname + '/util' ),
39 39
40 40 /**
41 41 * Responsible for building class members
  42 + *
  43 + * @param {Function} wrap_method method wrapper
  44 + * @param {Function} wrap_override method override wrapper
  45 + * @param {MemberBuilderValidator} validate member validator
  46 + *
  47 + * @constructor
42 48 */
43 49 module.exports = function MemberBuilder( wrap_method, wrap_override, validate )
44 50 {
@@ -69,7 +75,7 @@ exports = module.exports.prototype;
69 75 * @param {Object} mprotected default protected members
70 76 * @param {Object} mprivate default private members
71 77 *
72   - * @return {{public: Object, protected: Object, private: Object}}
  78 + * @return {__visobj}
73 79 */
74 80 exports.initMembers = function( mpublic, mprotected, mprivate )
75 81 {
@@ -85,17 +91,18 @@ exports.initMembers = function( mpublic, mprotected, mprivate )
85 91 * Copies a method to the appropriate member prototype, depending on
86 92 * visibility, and assigns necessary metadata from keywords
87 93 *
88   - * @param {{public: Object, protected: Object, private: Object}} members
  94 + * @param {__visobj} members
  95 + * @param {!Object} meta metadata container
  96 + * @param {string} name property name
  97 + * @param {*} value property value
89 98 *
90   - * @param {Object} meta metadata container
91   - * @param {string} name property name
92   - * @param {*} value property value
  99 + * @param {!Object.<boolean>} keywords parsed keywords
93 100 *
94   - * @param {Object.<string,boolean>} keywords parsed keywords
95   -
96   - * @param {Object=} instCallback function to call in order to retrieve
97   - * object to bind 'this' keyword to
98   - * @param {number} cid class id
  101 + * @param {Function} instCallback function to call in order to retrieve
  102 + * object to bind 'this' keyword to
  103 + *
  104 + * @param {number} cid class id
  105 + * @param {Object=} base optional base object to scan
99 106 *
100 107 * @return {undefined}
101 108 */
@@ -157,14 +164,13 @@ exports.buildMethod = function(
157 164 * Copies a property to the appropriate member prototype, depending on
158 165 * visibility, and assigns necessary metadata from keywords
159 166 *
160   - * @param {{public: Object, protected: Object, private: Object}} members
  167 + * @param {__visobj} members
  168 + * @param {!Object} meta metadata container
  169 + * @param {string} name property name
  170 + * @param {*} value property value
161 171 *
162   - * @param {Object} meta metadata container
163   - * @param {string} name property name
164   - * @param {*} value property value
  172 + * @param {!Object.<boolean>} keywords parsed keywords
165 173 *
166   - * @param {Object.<string,boolean>} keywords parsed keywords
167   -
168 174 * @param {Object=} base optional base object to scan
169 175 *
170 176 * @return {undefined}
@@ -190,18 +196,20 @@ exports.buildProp = function( members, meta, name, value, keywords, base )
190 196 * Copies a getter/setter to the appropriate member prototype, depending on
191 197 * visibility, and assigns necessary metadata from keywords
192 198 *
193   - * @param {{public: Object, protected: Object, private: Object}} members
194   - *
195   - * @param {Object} meta metadata container
196   - * @param {string} name getter name
197   - * @param {*} get getter value
198   - * @param {*} set setter value
  199 + * @param {!__visobj} members
  200 + * @param {!Object} meta metadata container
  201 + * @param {string} name getter name
  202 + * @param {*} get getter value
  203 + * @param {*} set setter value
199 204 *
200   - * @param {Object.<string,boolean>} keywords parsed keywords
  205 + * @param {!Object.<boolean>} keywords parsed keywords
201 206 *
202 207 * @param {Object=} base optional base object to scan
203 208 *
204 209 * @return {undefined}
  210 + *
  211 + * Closure Compiler is improperly throwing warnings on Object.defineProperty():
  212 + * @suppress {checkTypes}
205 213 */
206 214 exports.buildGetterSetter = function(
207 215 members, meta, name, get, set, keywords, base
@@ -238,10 +246,10 @@ exports.buildGetterSetter = function(
238 246 *
239 247 * Will throw an exception if multiple access modifiers were used.
240 248 *
241   - * @param {{public: Object, protected: Object, private: Object}} members
  249 + * @param {__visobj} members
242 250 *
243   - * @param {Object.<string,boolean>} keywords parsed keywords
244   - * @param {string} name member name
  251 + * @param {!Object.<boolean>} keywords parsed keywords
  252 + * @param {string} name member name
245 253 *
246 254 * @return {Object} reference to visibility of members argument to use
247 255 */
@@ -280,13 +288,12 @@ function getMemberVisibility( members, keywords, name )
280 288 /**
281 289 * Scan each level of visibility for the requested member
282 290 *
283   - * @param {{public: Object, protected: Object, private: Object}} members
  291 + * @param {__visobj} members
284 292 *
285 293 * @param {string} name member to locate
286 294 * @param {Object=} base optional base object to scan
287 295 *
288   - * @return {Object} Array of member and number corresponding to visibility,
289   - * level if located, otherwise an empty object
  296 + * @return {{get,set,member}|null}
290 297 */
291 298 function scanMembers( members, name, base )
292 299 {
@@ -358,9 +365,10 @@ function hideMethod( super_method, new_method, instCallback, cid )
358 365 * @param {function()} super_method method to override
359 366 * @param {function()} new_method method to override with
360 367 *
361   - * @param {Object=} instCallback function to call in order to retrieve
362   - * object to bind 'this' keyword to
363   - * @param {number} cid class id
  368 + * @param {Function} instCallback function to call in order to retrieve
  369 + * object to bind 'this' keyword to
  370 + *
  371 + * @param {number} cid class id
364 372 *
365 373 * @return {function()} override method
366 374 */
14 lib/MethodWrapperFactory.js
@@ -25,19 +25,19 @@
25 25 /**
26 26 * Initializes factory to wrap methods
27 27 *
28   - * @param {function()} getInst function to determine instance and return
29   - * associated visibility object
  28 + * @param {function(Function,Function,number)} factory function that will
  29 + * perform the actual
  30 + * wrapping
30 31 *
31   - * @param {function(function(),function(),number)} factory function that will
32   - * perform the actual
33   - * wrapping
  32 + * @constructor
34 33 */
35 34 module.exports = exports = function MethodWrapperFactory( factory )
36 35 {
37 36 // permit omission of the 'new' keyword for instantiation
38 37 if ( !( this instanceof exports ) )
39 38 {
40   - return new exports( factory );
  39 + // module.exports for Closure Compiler
  40 + return new module.exports( factory );
41 41 }
42 42
43 43 this._factory = factory;
@@ -53,6 +53,8 @@ module.exports = exports = function MethodWrapperFactory( factory )
53 53 * @param {function()} method method to wrap
54 54 * @param {function()} super_method super method, if overriding
55 55 * @param {number} cid class id that method is associated with
  56 + * @param {function()} getInst function to determine instance and return
  57 + * associated visibility object
56 58 */
57 59 exports.prototype.wrapMethod = function( method, super_method, cid, getInst )
58 60 {
9 lib/VisibilityObjectFactory.js
@@ -33,13 +33,17 @@ var util = require( __dirname + '/util' );
33 33 * The visibility object is the "magic" behind ease.js. This factory creates the
34 34 * object that holds the varying levels of visibility, which are swapped out and
35 35 * inherited depending on circumstance.
  36 + *
  37 + * @constructor
36 38 */
37 39 module.exports = exports = function VisibilityObjectFactory()
38 40 {
39 41 // permit omitting 'new' keyword
40 42 if ( !( this instanceof exports ) )
41 43 {
42   - return new exports();
  44 + // module.exports instead of exports because Closure Compiler seems to
  45 + // be confused
  46 + return new module.exports();
43 47 }
44 48 };
45 49
@@ -105,6 +109,7 @@ exports.prototype.setup = function setup( dest, properties, methods )
105 109 */
106 110 exports.prototype._createPrivateLayer = function( atop_of, properties )
107 111 {
  112 + /** @constructor */
108 113 var obj_ctor = function() {};
109 114 obj_ctor.prototype = atop_of;
110 115
@@ -126,7 +131,7 @@ exports.prototype._createPrivateLayer = function( atop_of, properties )
126 131 *
127 132 * @param {Object} dest destination object
128 133 * @param {Object} properties properties to copy
129   - * @param {Object=} methods methods to copy
  134 + * @param {Object} methods methods to copy
130 135 * @param {boolean} unless_keyword do not set if keyword is set on existing
131 136 * method
132 137 *
4 lib/VisibilityObjectFactoryFactory.js
@@ -19,6 +19,10 @@
19 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 20 *
21 21 * @author Mike Gerwitz
  22 + * @package core
  23 + *
  24 + * XXX: Figure out how to resolve Closure Compiler's warning about shared type
  25 + * information
22 26 */
23 27
24 28 // XXX: Tightly coupled
41 lib/class.js
@@ -55,14 +55,14 @@ var util = require( __dirname + '/util' ),
55 55 * use the class's extend() method. If unavailable (or extending a non-ease.js
56 56 * class/object), use the module's extend() method.
57 57 *
58   - * @param {string=} name optional name
59   - * @param {Object} def class definition
  58 + * @param {string|Object} namedef optional name or definition
  59 + * @param {Object=} def class definition if first argument is name
60 60 *
61   - * @return {Class} new class
  61 + * @return {Function|Object} new class or staging object
62 62 */
63   -module.exports = function()
  63 +module.exports = function( namedef, def )
64 64 {
65   - var type = typeof arguments[ 0 ],
  65 + var type = ( typeof namedef ),
66 66 result = null
67 67 ;
68 68
@@ -93,11 +93,12 @@ module.exports = function()
93 93 * Creates a class, inheriting either from the provided base class or the
94 94 * default base class
95 95 *
96   - * @param {Object} base object to extend (extends Class by default)
  96 + * @param {Function|Object} baseordfn parent or definition object
  97 + * @param {Object=} dfn definition object if parent provided
97 98 *
98   - * @return {Object} extended class
  99 + * @return {Function} extended class
99 100 */
100   -module.exports.extend = function( base )
  101 +module.exports.extend = function( baseordfn, dfn )
101 102 {
102 103 return extend.apply( this, arguments );
103 104 };
@@ -106,11 +107,11 @@ module.exports.extend = function( base )
106 107 /**
107 108 * Implements an interface or set of interfaces
108 109 *
109   - * @param {...Interface} interfaces interfaces to implement
  110 + * @param {...Function} interfaces interfaces to implement
110 111 *
111   - * @return {Class} new class containing interface abstractions
  112 + * @return {Object} intermediate interface object
112 113 */
113   -module.exports.implement = function()
  114 +module.exports.implement = function( interfaces )
114 115 {
115 116 // implement on empty base
116 117 return createImplement(
@@ -188,7 +189,7 @@ module.exports.isA = module.exports.isInstanceOf;
188 189 *
189 190 * @param {Object} def class definition
190 191 *
191   - * @return {Class} new anonymous class
  192 + * @return {Function} new anonymous class
192 193 */
193 194 function createAnonymousClass( def )
194 195 {
@@ -213,7 +214,8 @@ function createAnonymousClass( def )
213 214 * @param {string} name class name
214 215 * @param {Object} def class definition
215 216 *
216   - * @return {Class} new named class
  217 + * @return {Function|Object} new named class or staging object if definition
  218 + * was not provided
217 219 */
218 220 function createNamedClass( name, def )
219 221 {
@@ -368,9 +370,12 @@ function createImplement( base, ifaces, cname )
368 370 * The class to inherit from (the first argument) is optional. If omitted, the
369 371 * first argument will be considered to be the properties list.
370 372 *
371   - * @return {Object} extended class
  373 + * @param {Function|Object} _ parent or definition object
  374 + * @param {Object=} __ definition object if parent was provided
  375 + *
  376 + * @return {Function} extended class
372 377 */
373   -function extend()
  378 +function extend( _, __ )
374 379 {
375 380 // set up the new class
376 381 var new_class = class_builder.build.apply( class_builder, arguments );
@@ -392,12 +397,12 @@ function extend()
392 397 * This will copy all of the abstract methods from the interface and merge it
393 398 * into the given object.
394 399 *
395   - * @param {Object} base base object
396   - * @param {...Interface} interfaces interfaces to implement into dest
  400 + * @param {Object} baseobj base object
  401 + * @param {...Function} interfaces interfaces to implement into dest
397 402 *
398 403 * @return {Object} destination object with interfaces implemented
399 404 */
400   -var implement = function()
  405 +var implement = function( baseobj, interfaces )
401 406 {
402 407 var args = Array.prototype.slice.call( arguments ),
403 408 dest = {},
6 lib/class_abstract.js
@@ -31,7 +31,7 @@ var Class = require( __dirname + '/class' );
31 31 /**
32 32 * Creates an abstract class
33 33 *
34   - * @return {Class} abstract class
  34 + * @return {Function} abstract class
35 35 */
36 36 module.exports = exports = function()
37 37 {
@@ -54,7 +54,7 @@ module.exports = exports = function()
54 54 /**
55 55 * Creates an abstract class from a class extend operation
56 56 *
57   - * @return {Class} abstract class
  57 + * @return {Function} abstract class
58 58 */
59 59 exports.extend = function()
60 60 {
@@ -85,7 +85,7 @@ exports.implement = function()
85 85 * This function assumes the last argument to be the definition, which is the
86 86 * common case, and modifies the object referenced by that argument.
87 87 *
88   - * @param {arguments} args arguments to parse
  88 + * @param {Arguments} args arguments to parse
89 89 *
90 90 * @return {undefined}
91 91 */
6 lib/class_final.js
@@ -27,7 +27,7 @@ var Class = require( __dirname + '/class' );
27 27 /**
28 28 * Creates a final class
29 29 *
30   - * @return {Class} final class
  30 + * @return {Function} final class
31 31 */
32 32 exports = module.exports = function()
33 33 {
@@ -48,7 +48,7 @@ exports = module.exports = function()
48 48 /**
49 49 * Creates a final class from a class extend operation
50 50 *
51   - * @return {Class} final class
  51 + * @return {Function} final class
52 52 */
53 53 exports.extend = function()
54 54 {
@@ -63,7 +63,7 @@ exports.extend = function()
63 63 * This function assumes the last argument to be the definition, which is the
64 64 * common case, and modifies the object referenced by that argument.
65 65 *
66   - * @param {arguments} args arguments to parse
  66 + * @param {!Arguments} args arguments to parse
67 67 *
68 68 * @return {undefined}
69 69 */
16 lib/interface.js
@@ -44,14 +44,14 @@ var util = require( __dirname + '/util' ),
44 44 * extended. To extend an existing interface, call its extend() method, or use
45 45 * the extend() method of this module.
46 46 *
47   - * @param {string=} name optional name
48   - * @param {Object} def interface definition
  47 + * @param {string|Object} namedef optional name or definition
  48 + * @param {Object=} def interface definition if first arg is name
49 49 *
50   - * @return {Interface} new interface
  50 + * @return {Function|Object} new interface or staging object
51 51 */
52   -module.exports = function()
  52 +module.exports = function( namedef, def )
53 53 {
54   - var type = typeof arguments[ 0 ],
  54 + var type = ( typeof namedef ),
55 55 result = null
56 56 ;
57 57
@@ -82,7 +82,7 @@ module.exports = function()
82 82 /**
83 83 * Creates an interface
84 84 *
85   - * @return {Interface} extended interface
  85 + * @return {Function} extended interface
86 86 */
87 87 module.exports.extend = function()
88 88 {
@@ -123,7 +123,7 @@ function Interface() {}
123 123 *
124 124 * @param {Object} def interface definition
125 125 *
126   - * @return {Interface} new anonymous interface
  126 + * @return {Function} new anonymous interface
127 127 */
128 128 function createAnonymousInterface( def )
129 129 {
@@ -148,7 +148,7 @@ function createAnonymousInterface( def )
148 148 * @param {string} name interface name
149 149 * @param {Object} def interface definition
150 150 *
151   - * @return {Interface} new named interface
  151 + * @return {Function} new named interface
152 152 */
153 153 function createNamedInterface( name, def )
154 154 {
64 lib/util.js
@@ -103,7 +103,7 @@ exports.definePropertyFallback = function( val )
103 103 *
104 104 * @param {Object} obj object to set property on
105 105 * @param {string} prop name of property to set
106   - * @param {mixed} value value to set
  106 + * @param {*} value value to set
107 107 *
108 108 * @return {undefined}
109 109 */
@@ -113,10 +113,13 @@ exports.defineSecureProp = getDefineSecureProp();
113 113 /**
114 114 * Clones an object
115 115 *
116   - * @param {Object} data object to clone
117   - * @param {boolean} deep perform deep clone (defaults to shallow)
  116 + * @param {*} data object to clone
  117 + * @param {boolean=} deep perform deep clone (defaults to shallow)
118 118 *
119   - * @return {Object} cloned object
  119 + * @return {*} cloned object
  120 + *
  121 + * Closure Compiler ignores typeof checks and is thusly confused:
  122 + * @suppress {checkTypes}
120 123 */
121 124 exports.clone = function clone( data, deep )
122 125 {
@@ -147,7 +150,7 @@ exports.clone = function clone( data, deep )
147 150 // support toSource(), they'd still do the same damn thing.
148 151 return data;
149 152 }
150   - else if ( data instanceof Object )
  153 + else if ( typeof data === 'object' )
151 154 {
152 155 var newobj = {},
153 156 hasOwn = Object.prototype.hasOwnProperty;
@@ -247,8 +250,10 @@ exports.copyTo = function( dest, src, deep )
247 250 * Parses object properties to determine how they should be interpreted in an
248 251 * Object Oriented manner
249 252 *
250   - * @param {Object} data properties with names as the key
251   - * @param {Object} options parser options and callbacks
  253 + * @param {!Object} data properties with names as the key
  254 + *
  255 + * @param {!{each,property,method,getset,keywordParser}} options
  256 + * parser options and callbacks
252 257 *
253 258 * @return undefined
254 259 */
@@ -352,12 +357,12 @@ exports.propParse = function( data, options )
352 357 * considered to be abstract and cannot be instantiated. It may only be
353 358 * extended.
354 359 *
355   - * @param {...string} definition function definition that concrete
356   - * implementations must follow
  360 + * @param {...string} def function definition that concrete
  361 + * implementations must follow
357 362 *
358   - * @return {Function}
  363 + * @return {function()}
359 364 */
360   -exports.createAbstractMethod = function()
  365 +exports.createAbstractMethod = function( def )
361 366 {
362 367 var definition = Array.prototype.slice.call( arguments );
363 368
@@ -377,9 +382,11 @@ exports.createAbstractMethod = function()
377 382 /**
378 383 * Determines if the given function is an abstract method
379 384 *
380   - * @param {Function} function function to inspect
  385 + * @param {function()} func function to inspect
381 386 *
382 387 * @return {boolean} true if function is an abstract method, otherwise false
  388 + *
  389 + * @suppress {checkTypes}
383 390 */
384 391 exports.isAbstractMethod = function( func )
385 392 {
@@ -424,21 +431,22 @@ exports.arrayShrink = function( items )
424 431 /**
425 432 * Uses Object.getOwnPropertyDescriptor if available, otherwise provides our own
426 433 * implementation to fall back on
427   - *
428   - * If the environment does not support retrieving property descriptors (ES5),
429   - * then the following will be true:
430   - * - get/set will always be undefined
431   - * - writable, enumerable and configurable will always be true
432   - * - value will be the value of the requested property on the given object
433   - *
434   - * @param {Object} obj object to check property on
435   - * @param {string} prop property to retrieve descriptor for
436   - *
437   - * @return {Object} descriptor for requested property or undefined if not found
438 434 */
439 435 exports.getOwnPropertyDescriptor =
440   - ( can_define_prop && Object.getOwnPropertyDescriptor )
441   - || function( obj, prop )
  436 + ( can_define_prop && Object.getOwnPropertyDescriptor ) ||
  437 + /**
  438 + * If the environment does not support retrieving property descriptors
  439 + * (ES5), then the following will be true:
  440 + * - get/set will always be undefined
  441 + * - writable, enumerable and configurable will always be true
  442 + * - value will be the value of the requested property on the given object
  443 + *
  444 + * @param {!Object} obj object to check property on
  445 + * @param {string} prop property to retrieve descriptor for
  446 + *
  447 + * @return {Object|undefined} descriptor for requested property, if found
  448 + */
  449 + function( obj, prop )
442 450 {
443 451 if ( !Object.prototype.hasOwnProperty.call( obj, prop ) )
444 452 {
@@ -481,9 +489,9 @@ exports.getPrototypeOf = Object.getPrototypeOf || function()
481 489 * for example, not catch properties like Object.prototype.toString() when
482 490 * searching for 'toString' on an object.
483 491 *
484   - * @param {Object} obj object to check property on
485   - * @param {string} prop property to retrieve descriptor for
486   - * @param {bool} nobase whether to ignore the base prototype
  492 + * @param {Object} obj object to check property on
  493 + * @param {string} prop property to retrieve descriptor for
  494 + * @param {boolean} nobase whether to ignore the base prototype
487 495 *
488 496 * @return {Object} descriptor for requested property or undefined if not found
489 497 */
4 lib/warn.js
@@ -23,7 +23,7 @@
23 23
24 24 /**
25 25 * Active warning handler
26   - * @type {function()}
  26 + * @type {?function( Warning )}
27 27 */
28 28 var _handler = null;
29 29
@@ -47,6 +47,8 @@ var _console = ( typeof console !== 'undefined' ) ? console : undefined;
47 47 * @param {Error} e exception (error) to wrap
48 48 *
49 49 * @return {Warning} new warning instance
  50 + *
  51 + * @constructor
50 52 */
51 53 var Warning = exports.Warning = function( e )
52 54 {
4 tools/combine.tpl
@@ -36,7 +36,9 @@ var easejs = {};
36 36 *
37 37 * @param {string} module_id id of the module to load
38 38 *
39   - * @return {Object} exports of requested module
  39 + * return tag intentionally omitted; too many potential return types and
  40 + * setting return type of {*} will throw warnings for those attempting to
  41 + * treat the return value as a function
40 42 */
41 43 var require = function( module_id )
42 44 {
4 tools/externs.js
... ... @@ -0,0 +1,4 @@
  1 +/**
  2 + * Externs for ease.js
  3 + */
  4 +
14 tools/mkexterns
@@ -4,9 +4,6 @@
4 4 # have restricted scope. This means that they cannot be used as types in other
5 5 # modules. Therefore, to permit this, we must generate an extern file containing
6 6 # basic definitions of each.
7   -#
8   -# This is used only for compilation and is otherwise completely unnecessary. As
9   -# such, to reduce maintenance overhead, the creation of this file is automated.
10 7 # #
11 8
12 9 # all CamelCase modules are likely to be ctors
@@ -21,3 +18,14 @@ for module in $modules; do
21 18 echo "function $module() {};"
22 19 echo
23 20 done
  21 +
  22 +# finally, there's some additional useful metadata that we use to make our lives
  23 +# easier, better documented and more consistent
  24 +cat <<ETC
  25 +
  26 +/** @typedef {{abstractMethods: Object}} */
  27 +var __class_meta;
  28 +
  29 +/** @typedef {{public: Object, protected: Object, private: Object}} */
  30 +var __visobj;
  31 +ETC

0 comments on commit e247845

Please sign in to comment.
Something went wrong with that request. Please try again.