mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
While Closure Compiler generally recommends to maintain the externs for projects together with their source, this has not worked well for AngularJS: - Changes to externs must be tested; they can break clients. AngularJS has no testing infrastructure for this. - Changes mostly come from users inside of Google and are much more easily submitted together with the code using them within Google's repository. This change deletes the externs here and adds a README.closure.md to document the change. They will be added back to Closure Compiler in a separate submit. Closes #5906
929 B
929 B
Using AngularJS with the Closure Compiler
The Closure Compiler project contains externs definitions for AngularJS
JavaScript in its contrib/externs directory.
The definitions contain externs for use with the Closure compiler (aka JSCompiler). Passing these files to the --externs parameter of a compiler pass allows using type annotations for AngularJS objects. For example, Angular's $scope objects can be annotated as:
/** @type {angular.Scope} */
var scope = $scope;
This allows JSCompiler to type check accesses to scope, give warnings about missing methods or incorrect arguments, and also prevents renaming of property accesses with advanced compilation.
The externs are incomplete and maintained on an as-needed basis, but strive to be correct. Externs for individual modules should be added in separate files.