javascript-externs-generator
javascript-externs-generator copied to clipboard
Test Closure Compiler behavior with different extern fomats
Looking at the externs contained in https://github.com/google/closure-compiler/tree/master/contrib/externs, it seems like only the top-level namespace and the prototypes are defined. Is it actually necessary to recurse into everything?
e.g.
var namespace = {
property: {
anotherProperty: 1234
}
};
If we use namespace.property.anotherProperty
inside a program, do we need to provide externs for namespace.property.anotherProperty
, or does namespace.property
suffice?
https://github.com/google/closure-compiler/blob/master/contrib/externs/maps/google_maps_api_v3.js also includes enum properties. Is this necessary or is it an optimization? If an optimization, what does it do/allow?
Ideas for how to test this issue (#22) and others related to Closure Compiler behavior (#10, #9, #1):
- Make requests to the Closure Compiler Service API and inspect the output
Things to test:
- Are nested properties necessary
- Do we need to define the
prototype
, or can we just specify properties of an object - Do we even have to make the distinction between a function and an object
Probably easier to run on the command line: closure-compiler --compilation_level ADVANCED [--externs externs.js,] --js file.js[,] [--js_output_file output.js]