Skip to content

Instantly share code, notes, and snippets.

@ahamid ahamid/gist:3777562
Created Sep 24, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.