Created
September 24, 2012 18:44
-
-
Save ahamid/3777562 to your computer and use it in GitHub Desktop.
google closure compiler, type in IIFE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @typedef {Object} | |
*/ | |
var vendor = Vendor = {}; | |
///** | |
// * @constructor | |
// */ | |
//Vendor.VendorType = function() {}; | |
(function(vendor) { | |
/** | |
* @constructor | |
*/ | |
function VendorType() { this.a = "a"; }; | |
vendor.VendorType = VendorType; | |
/** | |
* @return {VendorType} the vendor type | |
*/ | |
function createIt() { | |
return new vendor.VendorType(); | |
} | |
})(vendor); | |
/** | |
* @return {Vendor.VendorType} a constructor-defined type | |
*/ | |
function createTheThing() { | |
return new Vendor.VendorType(); | |
} | |
console.log(createTheThing()); | |
========================== | |
java -jar lib/compiler.jar --jscomp_error checkTypes --compilation_level SIMPLE_OPTIMIZATIONS type.js | |
type.js:28: ERROR - Bad type annotation. Unknown type Vendor.VendorType | |
* @return {Vendor.VendorType} a constructor-defined type | |
^ | |
1 error(s), 0 warning(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment