Skip to content

Instantly share code, notes, and snippets.

@ahamid
Created September 24, 2012 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahamid/3777562 to your computer and use it in GitHub Desktop.
Save ahamid/3777562 to your computer and use it in GitHub Desktop.
google closure compiler, type in IIFE
/**
* @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