| OLD | NEW |
| (Empty) | |
| 1 function badFuncNoAnnotation() { |
| 2 return 1; // ERROR - no @return annotation. |
| 3 } |
| 4 |
| 5 /** |
| 6 * @return {number} |
| 7 */ |
| 8 function badFuncAnnotatedButNoReturn() // ERROR - no @return annotation. |
| 9 { |
| 10 } |
| 11 |
| 12 /** |
| 13 * @return {number} |
| 14 */ |
| 15 function badFuncAnnotatedButNoReturnValue() // ERROR - no returned value. |
| 16 { |
| 17 return; |
| 18 } |
| 19 |
| 20 /** |
| 21 * @return {number} |
| 22 */ |
| 23 function goodFunc() // OK - annotated @return. |
| 24 { |
| 25 return 1; |
| 26 } |
| 27 |
| 28 /** |
| 29 * @returns {number} |
| 30 */ |
| 31 function badReturnsShouldBeReturnFunc() // ERROR - @returns, should be @return. |
| 32 { |
| 33 return 1; |
| 34 } |
| 35 |
| 36 /** |
| 37 * @return number |
| 38 */ |
| 39 function badReturnShouldBeTypedFunc() // ERROR - number, not {number}. |
| 40 { |
| 41 return 1; |
| 42 } |
| 43 |
| 44 /** |
| 45 * @param number foo |
| 46 * @param bar |
| 47 */ |
| 48 function badParamAnnotationsFunc(foo, bar) // ERROR - @param's should be well-fo
rmed |
| 49 { |
| 50 return 1; |
| 51 } |
| 52 |
| 53 |
| 54 /** |
| 55 * @returns {number} |
| 56 */ |
| 57 function badReturnsShouldBeReturnNoValueFunc() // ERROR - @returns, should be @r
eturn. |
| 58 { |
| 59 return; |
| 60 } |
| 61 |
| 62 /** |
| 63 * @returns {number} |
| 64 */ |
| 65 function badReturnsShouldBeAbsentFunc() // ERROR - @returns, should be absent. |
| 66 { |
| 67 } |
| 68 |
| 69 /** |
| 70 * @constructor |
| 71 */ |
| 72 function TypeOne() { |
| 73 function callback() // OK - not a method. |
| 74 { |
| 75 return 1; |
| 76 } |
| 77 } |
| 78 |
| 79 TypeOne.prototype = { |
| 80 badApiMethodNoAnnotation: function() // ERROR - public method. |
| 81 { |
| 82 return 1; |
| 83 }, |
| 84 |
| 85 _privateMethod: function() // OK - non-public method. |
| 86 { |
| 87 var obj = {}; |
| 88 |
| 89 /** |
| 90 * @constructor |
| 91 * @param {number} val |
| 92 */ |
| 93 obj["a"] = obj["b"] = function(val) { // OK - constructor |
| 94 this.foo = val; |
| 95 } |
| 96 |
| 97 /** |
| 98 * @param {number} val |
| 99 */ |
| 100 obj["c"] = obj["d"] = function(val) { // ERROR - no @this |
| 101 this.foo = val; |
| 102 } |
| 103 |
| 104 return 1; |
| 105 }, |
| 106 |
| 107 methodTwo: function() |
| 108 { |
| 109 function callback() // OK - not a method. |
| 110 { |
| 111 return 1; |
| 112 } |
| 113 }, |
| 114 |
| 115 /** |
| 116 * @return {number} |
| 117 */ |
| 118 methodThatThrows: function() // OK - throws and should be overridden in subc
lasses. |
| 119 { |
| 120 throw "Not implemented"; |
| 121 }, |
| 122 |
| 123 /** |
| 124 * @return {number} |
| 125 */ |
| 126 badMethodDoesNotReturnValue: function() // ERROR - does not return value. |
| 127 { |
| 128 return; |
| 129 }, |
| 130 |
| 131 /** |
| 132 * @return {number} |
| 133 */ |
| 134 badMethodDoesNotReturn: function() // ERROR - does not return. |
| 135 { |
| 136 var foo = 1; |
| 137 }, |
| 138 |
| 139 /** |
| 140 * @returns {number} |
| 141 */ |
| 142 badMethodReturnsShouldBeReturn: function() // ERROR - @returns, should be @r
eturn |
| 143 { |
| 144 return 1; |
| 145 }, |
| 146 |
| 147 /** |
| 148 * @returns {number} |
| 149 */ |
| 150 badMethodReturnsShouldBeAbsentToo: function() // ERROR - @returns, should be
absent |
| 151 { |
| 152 return; |
| 153 }, |
| 154 |
| 155 /** |
| 156 * @returns {number} |
| 157 */ |
| 158 badMethodReturnsShouldBeAbsent: function() // ERROR - @returns, should be ab
sent |
| 159 { |
| 160 var foo = 1; |
| 161 } |
| 162 } |
| 163 |
| 164 |
| 165 /** |
| 166 * @constructor |
| 167 */ |
| 168 TypeTwo = function() { |
| 169 function callback() // OK - not a method. |
| 170 { |
| 171 return 1; |
| 172 } |
| 173 } |
| 174 |
| 175 TypeTwo.prototype = { |
| 176 badApiMethodNoAnnotation: function() // ERROR - public method. |
| 177 { |
| 178 return 1; |
| 179 }, |
| 180 |
| 181 _privateMethod: function() // OK - non-public method. |
| 182 { |
| 183 return 1; |
| 184 }, |
| 185 |
| 186 methodTwo: function() |
| 187 { |
| 188 function callback() // OK - not a method. |
| 189 { |
| 190 return 1; |
| 191 } |
| 192 }, |
| 193 |
| 194 /** |
| 195 * @return {number} |
| 196 */ |
| 197 badMethodDoesNotReturnValue: function() // ERROR - does not return value. |
| 198 { |
| 199 return; |
| 200 }, |
| 201 |
| 202 /** |
| 203 * @return {number} |
| 204 */ |
| 205 badMethodDoesNotReturn: function() // ERROR - does not return. |
| 206 { |
| 207 var foo = 1; |
| 208 }, |
| 209 |
| 210 /** |
| 211 * @returns {number} |
| 212 */ |
| 213 badMethodReturnsShouldBeReturn: function() // ERROR - @returns, should be @r
eturn |
| 214 { |
| 215 return 1; |
| 216 }, |
| 217 |
| 218 /** |
| 219 * @returns {number} |
| 220 */ |
| 221 badMethodReturnsShouldBeAbsentToo: function() // ERROR - @returns, should be
absent |
| 222 { |
| 223 return; |
| 224 }, |
| 225 |
| 226 /** |
| 227 * @returns {number} |
| 228 */ |
| 229 badMethodReturnsShouldBeAbsent: function() // ERROR - @returns, should be ab
sent |
| 230 { |
| 231 var foo = 1; |
| 232 } |
| 233 } |
| 234 |
| 235 /** |
| 236 * @interface |
| 237 */ |
| 238 Interface = function() {} |
| 239 |
| 240 Interface.prototype = { |
| 241 /** |
| 242 * @return {number} |
| 243 */ |
| 244 interfaceMethod: function() {}, // OK - interface method. |
| 245 |
| 246 /** |
| 247 * @returns {number} |
| 248 */ |
| 249 badReturnsInterfaceMethod: function() {} // ERROR - @returns instead of retu
rn. |
| 250 } |
| 251 |
| 252 /** |
| 253 * @return {!Object} |
| 254 */ |
| 255 function returnConstructedObject() { |
| 256 |
| 257 /** |
| 258 * @constructor |
| 259 */ |
| 260 TypeThree = function() { |
| 261 function callback() // OK - not a method. |
| 262 { |
| 263 return 1; |
| 264 } |
| 265 } |
| 266 |
| 267 TypeThree.prototype = { |
| 268 badApiMethodNoAnnotation: function() // ERROR - public method. |
| 269 { |
| 270 return 1; |
| 271 }, |
| 272 |
| 273 _privateMethod: function() // OK - non-public method. |
| 274 { |
| 275 return 1; |
| 276 }, |
| 277 |
| 278 methodTwo: function() |
| 279 { |
| 280 function callback() // OK - not a method. |
| 281 { |
| 282 return 1; |
| 283 } |
| 284 }, |
| 285 |
| 286 /** |
| 287 * @return {number} |
| 288 */ |
| 289 badMethodDoesNotReturnValue: function() // ERROR - does not return value. |
| 290 { |
| 291 return; |
| 292 }, |
| 293 |
| 294 /** |
| 295 * @return {number} |
| 296 */ |
| 297 badMethodDoesNotReturn: function() // ERROR - does not return. |
| 298 { |
| 299 var foo = 1; |
| 300 }, |
| 301 |
| 302 /** |
| 303 * @returns {number} |
| 304 */ |
| 305 badMethodReturnsShouldBeReturn: function() // ERROR - @returns, should be @r
eturn |
| 306 { |
| 307 return 1; |
| 308 }, |
| 309 |
| 310 /** |
| 311 * @returns number |
| 312 */ |
| 313 badMethodReturnShouldBeTyped: function() // ERROR - number, not {number} |
| 314 { |
| 315 return 1; |
| 316 }, |
| 317 |
| 318 /** |
| 319 * @returns {number} |
| 320 */ |
| 321 badMethodReturnsShouldBeAbsentToo: function() // ERROR - @returns, should be
absent |
| 322 { |
| 323 return; |
| 324 }, |
| 325 |
| 326 /** |
| 327 * @returns {number} |
| 328 */ |
| 329 badMethodReturnsShouldBeAbsent: function() // ERROR - @returns, should be ab
sent |
| 330 { |
| 331 var foo = 1; |
| 332 }, |
| 333 |
| 334 /** |
| 335 * @param number foo |
| 336 * @param bar |
| 337 */ |
| 338 badMethodParamAnnotations: function(foo, bar) // ERROR - @param's should be
well-formed |
| 339 { |
| 340 return 1; |
| 341 } |
| 342 } |
| 343 |
| 344 return new TypeThree(); |
| 345 } |
| 346 |
| 347 |
| 348 /** |
| 349 * @param {string} a |
| 350 * @param {string} b |
| 351 * @param {string} c |
| 352 */ |
| 353 function funcParamsOK1(a, b, c) {} |
| 354 |
| 355 function funcParamsOK2(a, b, c) {} |
| 356 |
| 357 /** |
| 358 * @param {string} a |
| 359 * @param {string} c |
| 360 */ |
| 361 function funcParamsMissingTag1(a, b, c) {} |
| 362 |
| 363 /** |
| 364 * @param {string} a |
| 365 */ |
| 366 function funcParamsMissingTag2(a, b, c) {} |
| 367 |
| 368 /** |
| 369 * @interface |
| 370 */ |
| 371 function FuncInterface() |
| 372 { |
| 373 } |
| 374 |
| 375 FuncInterface.prototype = { |
| 376 /** |
| 377 * @return {number} |
| 378 */ |
| 379 returnNumber: function() { } |
| 380 } |
| OLD | NEW |