Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings about missing types from compiler #27

Closed
wolfgangmeyers opened this issue Mar 31, 2016 · 22 comments
Closed

Warnings about missing types from compiler #27

wolfgangmeyers opened this issue Mar 31, 2016 · 22 comments

Comments

@wolfgangmeyers
Copy link
Contributor

Types that are defined in extern files show up as undefined types in the compiler output. These are just warnings, and don't prevent the output of the closure_js_binary. I'll provide a reproduction scenario when I have time, logging this now before I forget.

@jart
Copy link
Contributor

jart commented Apr 1, 2016

Not following. Please show @externs definition and error message.

@wolfgangmeyers
Copy link
Contributor Author

closure-compile-warnings.zip
Note - I've included the closure/ subfolder from rules_closure to avoid #9

Run:
bazel build //:app_bin

And you will get the following warning (among other bogus warnings that are from angular-externs.js):

app.js:4: WARNING - Type annotation references non-existent type angular.Module.
 *  @type {angular.Module}
           ^

angular.Module is defined as a struct in angular-externs.js, however.

@wolfgangmeyers
Copy link
Contributor Author

I suspect this could be resolved by adding goog.provide(..) in the extern file and goog.require(...) in the code file.

@jart
Copy link
Contributor

jart commented Apr 1, 2016

Does the problem go away if you change:

closure_js_library(
    name = "app",
    srcs = ["app.js"],
    deps = ["@io_bazel_rules_closure//closure/library"],
)

closure_js_library(
    name = "ext",
    externs = ["angular-externs.js"],
)

closure_js_binary(
    name = "app_bin",
    deps = [
        ":app",
        ":ext",
    ],
    main = "foo.app",
    defs = [
        "--angular_pass",
        "--export_local_property_definitions",
    ],
)

To be:

closure_js_library(
    name = "app",
    srcs = ["app.js"],
    deps = [
         ":ext",
         "@io_bazel_rules_closure//closure/library",
    ],
)

closure_js_library(
    name = "ext",
    externs = ["angular-externs.js"],
)

closure_js_binary(
    name = "app_bin",
    deps = [":app"],
    main = "foo.app",
    defs = [
        "--angular_pass",
        "--export_local_property_definitions",
    ],
)

That should accurately depict the dependency graph.

@jart
Copy link
Contributor

jart commented Apr 1, 2016

Also you can't put goog.provide statements in externs files. They aren't executed. It's purely declarative code.

@jart
Copy link
Contributor

jart commented Apr 1, 2016

Also can you use bazel build -s //:app_bin to verify that an --externs=angular-externs.js flag is getting passed to the closure compiler?

@wolfgangmeyers
Copy link
Contributor Author

Adding the ":ext" dependency to app library did not make the warning go away. From running the build with -s, I saw '--externs=angular-externs.js' in the output, so apparently it is being included.

@jart
Copy link
Contributor

jart commented May 12, 2016

I'm not sure if this is a bug in Closure Rules. I'm not sure what's going on, but it seems like it might be something that should be escalated to https://github.com/google/closure-compiler if it continues to present problems.

@jart jart closed this as completed May 12, 2016
@wolfgangmeyers
Copy link
Contributor Author

I'm not sure either. When I ran the closure compiler in a standalone fashion, the warnings weren't there, but it's possible that either the usage or the version of the compilers is different in each case. When I have time I'll see if I can reproduce the problem with the standalone compiler, and reopen if necessary.

@jart
Copy link
Contributor

jart commented May 12, 2016

Thank you.

@aproxs
Copy link

aproxs commented Jun 22, 2016

@wolfgangmeyers, @jart , I'm getting the same behavior mentioned in this bug.

I downloaded Wolfang's code and started playing around with the closure compiler command line and I if you add "--hide_warnings_for=angular-externs.js" you significantly reduce the noise.
You still get a:

app.js:4: WARNING - Type annotation references non-existent type angular.Module.
 *  @type {angular.Module}
           ^

Which means that the underlying issue is still there but this could be a temporary workaround to reduce the output noise.

It should be as easy as adding the following to your closure_js_binary:

defs=["--hide_warnings_for=your/path/to/externs"]

@jart
Copy link
Contributor

jart commented Jun 22, 2016

@aproxs Does your closure_js_library reference the angular externs? For example:

http_file(
    name = "angular_externs",
    url = "https://raw.githubusercontent.com/google/closure-compiler/maven-v20160517/contrib/externs/angular-1.5.js",
    sha256 = "c7fcda4d045e92c7d1624a98624429af93d54bd0ef7182d1093ec1bdca0d5b77",
)

closure_js_library(
    name = "angular",
    externs = ["@angular_externs//file"],
)

closure_js_library(
    name = "foo_lib",
    srcs = ["foo.js"],
    deps = [":angular"],
)

That should fix the error about the angular.Module type being missing.

@aproxs
Copy link

aproxs commented Jul 6, 2016

Thanks @jart, I tried again making sure that all the files were there and the warning disappears.

However, adding angular-1.5.js to the externs seems to add around 90 warnings to my output, all coming from the angular extern, so seems that I still need the hide_warnings_for in the command line options to exclude warnings from externs.

I'm guessing that these are things that need to be fixed in the closure_compiler repo right?

@jart
Copy link
Contributor

jart commented Jul 6, 2016

@aproxs What are those warnings? Could you copy and paste them here? Looking at angular-1.5.js it doesn't appear to be poorly written.

@aproxs
Copy link

aproxs commented Jul 6, 2016

I agree, the angular-1.5* set seems pretty nice at first look.
Instead of pulling form a repo in bazel, I have the file copied in my workspace, but that should not matter as far as I understand.

Here is the output that I get. I think you can easily repro this with the files Wolfang shared earlier in this issue.

Again, from the text in the warnings seems like this could be legit issues in the angular-1.5* family of files.

webapp/js/externs/angular-1.5-http-promise_templated.js:36: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.Response = function() {};
^

webapp/js/externs/angular-1.5-http-promise_templated.js:55: WARNING - Type annotation references non-existent type angular.$http.Response.
 * @extends {angular.$q.Promise.<!angular.$http.Response.<T>>}
                                  ^

webapp/js/externs/angular-1.5-http-promise_templated.js:58: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.HttpPromise = function() {};
^

webapp/js/externs/angular-1.5-http-promise_templated.js:61: WARNING - Type annotation references non-existent type T.
 * @param {function(T, number, function(string=):
                    ^

webapp/js/externs/angular-1.5-http-promise_templated.js:63: WARNING - Type annotation references non-existent type angular.$http.HttpPromise.
 * @return {!angular.$http.HttpPromise.<T>} Promise for chaining.
             ^

webapp/js/externs/angular-1.5-http-promise_templated.js:69: WARNING - Type annotation references non-existent type angular.$http.Config.
 *     (string|Object|null), angular.$http.Config)} callback
                             ^

webapp/js/externs/angular-1.5-http-promise_templated.js:70: WARNING - Type annotation references non-existent type angular.$http.HttpPromise.
 * @return {!angular.$http.HttpPromise.<T>} Promise for chaining.
             ^

webapp/js/externs/angular-1.5.js:256: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.animate =
^

webapp/js/externs/angular-1.5.js:265: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.enter = function(element, doneFn, opt_options) {};
^

webapp/js/externs/angular-1.5.js:273: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.leave = function(element, doneFn, opt_options) {};
^

webapp/js/externs/angular-1.5.js:281: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.move = function(element, doneFn, opt_options) {};
^

webapp/js/externs/angular-1.5.js:290: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.beforeAddClass =
^

webapp/js/externs/angular-1.5.js:300: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.addClass =
^

webapp/js/externs/angular-1.5.js:310: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.beforeRemoveClass =
^

webapp/js/externs/angular-1.5.js:320: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.removeClass =
^

webapp/js/externs/angular-1.5.js:331: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.beforeSetClass =
^

webapp/js/externs/angular-1.5.js:342: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Animation.setClass =
^

webapp/js/externs/angular-1.5.js:417: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.LinkingFunctions.pre = function(scope, iElement, iAttrs, controller) {};
^

webapp/js/externs/angular-1.5.js:425: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.LinkingFunctions.post = function(scope, iElement, iAttrs, controller) {
^

webapp/js/externs/angular-1.5.js:964: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Scope.Event.currentScope;
^

webapp/js/externs/angular-1.5.js:967: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Scope.Event.defaultPrevented;
^

webapp/js/externs/angular-1.5.js:970: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Scope.Event.name;
^

webapp/js/externs/angular-1.5.js:972: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Scope.Event.preventDefault = function() {};
^

webapp/js/externs/angular-1.5.js:974: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Scope.Event.stopPropagation = function() {};
^

webapp/js/externs/angular-1.5.js:977: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.Scope.Event.targetScope;
^

webapp/js/externs/angular-1.5.js:1032: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$anchorScrollProvider.disableAutoScrolling = function() {};
^

webapp/js/externs/angular-1.5.js:1210: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$compile.LinkOptions;
^

webapp/js/externs/angular-1.5.js:1251: WARNING - Type annotation references non-existent type angular.$cacheFactory.Cache.
 * @return {!angular.$cacheFactory.Cache|undefined}
             ^

webapp/js/externs/angular-1.5.js:1256: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$cacheFactory.Options;
^

webapp/js/externs/angular-1.5.js:1262: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$cacheFactory.Cache = function() {};
^

webapp/js/externs/angular-1.5.js:1265: WARNING - Type annotation references non-existent type angular.$cacheFactory.Cache.Info.
 * @return {!angular.$cacheFactory.Cache.Info}
             ^

webapp/js/externs/angular-1.5.js:1271: WARNING - Type annotation references non-existent type T.
 * @param {T} value
           ^

webapp/js/externs/angular-1.5.js:1277: WARNING - Type annotation references non-existent type T.
 * @return {T}
            ^

webapp/js/externs/angular-1.5.js:1415: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$filter.orderBy;
^

webapp/js/externs/angular-1.5.js:1422: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$filter.filter;
^

webapp/js/externs/angular-1.5.js:1437: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$filterProvider.register = function(name, fn) {};
^

webapp/js/externs/angular-1.5.js:1449: WARNING - Type annotation references non-existent type angular.$http.Config.
 *   delete: function(string, angular.$http.Config=):!angular.$http.HttpPromise,
                              ^

webapp/js/externs/angular-1.5.js:1485: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.Config;
^

webapp/js/externs/angular-1.5.js:1503: WARNING - Type annotation references non-existent type angular.$http.Config.
 * @param {angular.$http.Config=} opt_config
           ^

webapp/js/externs/angular-1.5.js:1504: WARNING - Type annotation references non-existent type angular.$http.HttpPromise.
 * @return {!angular.$http.HttpPromise}
             ^

webapp/js/externs/angular-1.5.js:1506: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.get = function(url, opt_config) {};
^

webapp/js/externs/angular-1.5.js:1510: WARNING - Type annotation references non-existent type angular.$http.Config.
 * @param {angular.$http.Config=} opt_config
           ^

webapp/js/externs/angular-1.5.js:1511: WARNING - Type annotation references non-existent type angular.$http.HttpPromise.
 * @return {!angular.$http.HttpPromise}
             ^

webapp/js/externs/angular-1.5.js:1513: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.head = function(url, opt_config) {};
^

webapp/js/externs/angular-1.5.js:1517: WARNING - Type annotation references non-existent type angular.$http.Config.
 * @param {angular.$http.Config=} opt_config
           ^

webapp/js/externs/angular-1.5.js:1518: WARNING - Type annotation references non-existent type angular.$http.HttpPromise.
 * @return {!angular.$http.HttpPromise}
             ^

webapp/js/externs/angular-1.5.js:1520: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.jsonp = function(url, opt_config) {};
^

webapp/js/externs/angular-1.5.js:1525: WARNING - Type annotation references non-existent type angular.$http.Config.
 * @param {angular.$http.Config=} opt_config
           ^

webapp/js/externs/angular-1.5.js:1526: WARNING - Type annotation references non-existent type angular.$http.HttpPromise.
 * @return {!angular.$http.HttpPromise}
             ^

webapp/js/externs/angular-1.5.js:1528: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.patch = function(url, data, opt_config) {};
^

webapp/js/externs/angular-1.5.js:1533: WARNING - Type annotation references non-existent type angular.$http.Config.
 * @param {angular.$http.Config=} opt_config
           ^

webapp/js/externs/angular-1.5.js:1534: WARNING - Type annotation references non-existent type angular.$http.HttpPromise.
 * @return {!angular.$http.HttpPromise}
             ^

webapp/js/externs/angular-1.5.js:1536: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.post = function(url, data, opt_config) {};
^

webapp/js/externs/angular-1.5.js:1541: WARNING - Type annotation references non-existent type angular.$http.Config.
 * @param {angular.$http.Config=} opt_config
           ^

webapp/js/externs/angular-1.5.js:1542: WARNING - Type annotation references non-existent type angular.$http.HttpPromise.
 * @return {!angular.$http.HttpPromise}
             ^

webapp/js/externs/angular-1.5.js:1544: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.put = function(url, data, opt_config) {};
^

webapp/js/externs/angular-1.5.js:1549: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.defaults;
^

webapp/js/externs/angular-1.5.js:1555: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.pendingRequests;
^

webapp/js/externs/angular-1.5.js:1555: WARNING - This property cannot be @const. The @const annotation is only allowed for properties of namespaces, prototype properties, static properties of constructors, and properties of the form this.prop declared inside constructors and prototype methods.
angular.$http.pendingRequests;
^

webapp/js/externs/angular-1.5.js:1567: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$http.Interceptor;
^

webapp/js/externs/angular-1.5.js:1575: WARNING - Type annotation references non-existent type angular.$http.Config.
 * @type {angular.$http.Config}
          ^

webapp/js/externs/angular-1.5.js:1580: WARNING - Type annotation references non-existent type angular.$http.Interceptor.
 * @type {!Array.<string|function(...?): !angular.$http.Interceptor>}
                                          ^

webapp/js/externs/angular-1.5.js:1773: WARNING - Type annotation references non-existent type angular.$locationProvider.html5ModeConfig.
 * @param {(boolean|angular.$locationProvider.html5ModeConfig)=} opt_mode
                    ^

webapp/js/externs/angular-1.5.js:2066: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$parse.Expression;
^

webapp/js/externs/angular-1.5.js:2075: WARNING - Type annotation references non-existent type angular.$parse.Expression.
 * @type {angular.$parse.Expression}
          ^

webapp/js/externs/angular-1.5.js:2097: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$provide.Provider.$get;
^

webapp/js/externs/angular-1.5.js:2245: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$routeProvider.Params.controller;
^

webapp/js/externs/angular-1.5.js:2248: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$routeProvider.Params.controllerAs;
^

webapp/js/externs/angular-1.5.js:2251: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$routeProvider.Params.template;
^

webapp/js/externs/angular-1.5.js:2254: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$routeProvider.Params.templateUrl;
^

webapp/js/externs/angular-1.5.js:2257: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$routeProvider.Params.resolve;
^

webapp/js/externs/angular-1.5.js:2260: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$routeProvider.Params.redirectTo;
^

webapp/js/externs/angular-1.5.js:2263: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$routeProvider.Params.reloadOnSearch;
^

webapp/js/externs/angular-1.5.js:2310: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.HTML;
^

webapp/js/externs/angular-1.5.js:2310: WARNING - This property cannot be @const. The @const annotation is only allowed for properties of namespaces, prototype properties, static properties of constructors, and properties of the form this.prop declared inside constructors and prototype methods.
angular.$sce.HTML;
^

webapp/js/externs/angular-1.5.js:2313: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.CSS;
^

webapp/js/externs/angular-1.5.js:2313: WARNING - This property cannot be @const. The @const annotation is only allowed for properties of namespaces, prototype properties, static properties of constructors, and properties of the form this.prop declared inside constructors and prototype methods.
angular.$sce.CSS;
^

webapp/js/externs/angular-1.5.js:2316: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.URL;
^

webapp/js/externs/angular-1.5.js:2316: WARNING - This property cannot be @const. The @const annotation is only allowed for properties of namespaces, prototype properties, static properties of constructors, and properties of the form this.prop declared inside constructors and prototype methods.
angular.$sce.URL;
^

webapp/js/externs/angular-1.5.js:2319: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.JS;
^

webapp/js/externs/angular-1.5.js:2319: WARNING - This property cannot be @const. The @const annotation is only allowed for properties of namespaces, prototype properties, static properties of constructors, and properties of the form this.prop declared inside constructors and prototype methods.
angular.$sce.JS;
^

webapp/js/externs/angular-1.5.js:2322: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.RESOURCE_URL;
^

webapp/js/externs/angular-1.5.js:2322: WARNING - This property cannot be @const. The @const annotation is only allowed for properties of namespaces, prototype properties, static properties of constructors, and properties of the form this.prop declared inside constructors and prototype methods.
angular.$sce.RESOURCE_URL;
^

webapp/js/externs/angular-1.5.js:2325: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.isEnabled = function() {};
^

webapp/js/externs/angular-1.5.js:2330: WARNING - Type annotation references non-existent type angular.$parse.Expression.
 * @return {!angular.$parse.Expression}
             ^

webapp/js/externs/angular-1.5.js:2332: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.parseAs = function(type, expression) {};
^

webapp/js/externs/angular-1.5.js:2339: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.getTrusted = function(type, maybeTrusted) {};
^

webapp/js/externs/angular-1.5.js:2346: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.trustAs = function(type, trustedValue) {};
^

webapp/js/externs/angular-1.5.js:2350: WARNING - Type annotation references non-existent type angular.$parse.Expression.
 * @return {!angular.$parse.Expression}
             ^

webapp/js/externs/angular-1.5.js:2352: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.parseAsHtml = function(expression) {};
^

webapp/js/externs/angular-1.5.js:2356: WARNING - Type annotation references non-existent type angular.$parse.Expression.
 * @return {!angular.$parse.Expression}
             ^

webapp/js/externs/angular-1.5.js:2358: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.parseAsCss = function(expression) {};
^

webapp/js/externs/angular-1.5.js:2362: WARNING - Type annotation references non-existent type angular.$parse.Expression.
 * @return {!angular.$parse.Expression}
             ^

webapp/js/externs/angular-1.5.js:2364: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.parseAsUrl = function(expression) {};
^

webapp/js/externs/angular-1.5.js:2368: WARNING - Type annotation references non-existent type angular.$parse.Expression.
 * @return {!angular.$parse.Expression}
             ^

webapp/js/externs/angular-1.5.js:2370: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.parseAsJs = function(expression) {};
^

webapp/js/externs/angular-1.5.js:2374: WARNING - Type annotation references non-existent type angular.$parse.Expression.
 * @return {!angular.$parse.Expression}
             ^

webapp/js/externs/angular-1.5.js:2376: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.parseAsResourceUrl = function(expression) {};
^

webapp/js/externs/angular-1.5.js:2382: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.getTrustedHtml = function(maybeTrusted) {};
^

webapp/js/externs/angular-1.5.js:2388: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.getTrustedCss = function(maybeTrusted) {};
^

webapp/js/externs/angular-1.5.js:2394: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.getTrustedUrl = function(maybeTrusted) {};
^

webapp/js/externs/angular-1.5.js:2400: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.getTrustedJs = function(maybeTrusted) {};
^

webapp/js/externs/angular-1.5.js:2406: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.getTrustedResourceUrl = function(maybeTrusted) {};
^

webapp/js/externs/angular-1.5.js:2412: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.trustAsHtml = function(trustedValue) {};
^

webapp/js/externs/angular-1.5.js:2418: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.trustAsCss = function(trustedValue) {};
^

webapp/js/externs/angular-1.5.js:2424: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.trustAsUrl = function(trustedValue) {};
^

webapp/js/externs/angular-1.5.js:2430: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.trustAsJs = function(trustedValue) {};
^

webapp/js/externs/angular-1.5.js:2436: WARNING - A typedef should only be used in type annotations, not as a value. Adding properties to typedefs is not allowed.
angular.$sce.trustAsResourceUrl = function(trustedValue) {};
^

webapp/js/externs/angular-1.5.js:2531: WARNING - Found two declarations for property cancel on type Function.

angular.$timeout_.cancel = function(promise) {};
^

@jart
Copy link
Contributor

jart commented Jul 6, 2016

Oh dear, the way they're using @typedef is totally wrong. Take angular.Animation for instance. If you use @typedef, then you don't need to specify all the methods beneath it. They all go in the @typedef {...}. If you don't use @typedef then you need to use @constructor + @struct + @final definitions for the constructor of the class, and then define all the methods beneath it.

@jart
Copy link
Contributor

jart commented Jul 6, 2016

It should relatively simple for you to delete all those superfluous method definitions, and then send a pull request to google/closure-compiler.

@jart
Copy link
Contributor

jart commented Jul 6, 2016

Out of curiosity, did JsChecker catch this problem in the closure_js_library definition you wrote for these externs? I.e. did you have to suppress these warnings, and then also had to suppress them in the binary rule? If that's the case, then I apologize. It's a backburner item for me to integrate suppressions so they propagate up to the binary.

@aproxs
Copy link

aproxs commented Jul 6, 2016

Hmmm, seems that the library generates a different set of warnings than the binary, which I just found trying to confirm if JsChecker catches this.

From what I can tell, the library generates a much 'richer' set of warnings and errors than the binary and I am suspicious that the JsChecker and/or linter are not running for the binary in my project.

Here is a simplified version of my BUILD file:

load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_library")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_deps")

closure_js_library(
    name = "angular_lib",
    externs = [
        "externs/angular-1.5.js",
        "externs/angular-1.5-q_templated.js",
        "externs/angular-1.5-http-promise_templated.js",
        "externs/angular-material.js",
    ],
)

closure_js_library(
    name = "all_js_files",
    srcs = glob([
        "controllers/*.js",
        "filters/*.js",
        "directives/*.js",
        "services/*.js",
        "model/*.js",
    ], ["**/*_test.js", "**/*_mock.js"]),
 )

closure_js_library(
    name = "main_lib",
    srcs = [
        "mainModule.js",
    ],
    deps = [
        ":angular_lib",
        ":all_js_files",
        "@io_bazel_rules_closure//closure/library",
    ],
)

closure_js_binary(
    name = "webapp_bin",
    entry_points = ["goog:mainApp"],
    deps = [
        ":angular_lib",
        ":main_lib",
    ],
    language = "ECMASCRIPT5_STRICT",
    defs = [
        "--generate_exports",
        "--angular_pass",
        "--export_local_property_definitions",
        "--hide_warnings_for=externs/",
    ],
)

With that build file, I get no errors or warnings when I do:

bazel build :webapp_bin

but I get legit errors on missing dependencies and other real things when I build the library in isolation:

bazel build :main_lib

Is there anything missing in my BUILD file that could be causing the difference in behavior?

Let me fix the errors in my code and try to answer your question when I get a successful build.

@jart
Copy link
Contributor

jart commented Jul 6, 2016

Yeah the reason JsChecker didn't get invoked is due to a bug I fixed in c810b60 Before this, it would only get invoked if you ran bazel build //project/... or if you had another js library referencing that one. Sorry about that. I'll make a release probably today that incorporates that fix.

@aproxs
Copy link

aproxs commented Jul 8, 2016

Just tried with 0.2.3 and the JsChecker is now running consistently. Thanks @jart!

@jart
Copy link
Contributor

jart commented Jul 9, 2016

I'm glad I could help. Thank you for using Closure Rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants