New issue
Advanced search Search tips

Issue 882739 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

ui/webui/resources/js doesn't compile with strictCheckTypes

Project Member Reported by tapted@chromium.org, Sep 11

Issue description

Chrome Version       : 70.0.3534.4

strictCheckTypes was added to the closure compiler around February, 2018, and it's great.

Without it, annotating things as {Object} or {Element} can get code compiling, but with very little actual type-checking.

It also emits some errors for things never documented.

I'll probably tackle a few things that are affecting JS under src/ui/file_manager, but there's a big yak to shave here.


To repro, something like

js_type_check("closure_compile_module") {
  closure_flags = default_closure_args + [ "jscomp_error=strictCheckTypes" ]
  ...
}


There's probably a lot more, but here's a small set from things commonly used in unit tests.



../../ui/webui/resources/js/assert.js:27: ERROR - Property traceAssertionsForTesting never defined on global
    if (global.traceAssertionsForTesting)
               ^^^^^^^^^^^^^^^^^^^^^^^^^

../../ui/webui/resources/js/webui_resource_test.js:183: ERROR - Property setUpPage never defined on Object
    if (testScope.setUpPage)
                  ^^^^^^^^^

../../ui/webui/resources/js/webui_resource_test.js:219: ERROR - Property setUp never defined on Object
      if (testScope.setUp)
                    ^^^^^

../../ui/webui/resources/js/webui_resource_test.js:221: ERROR - Property tearDown never defined on Object
      pendingTearDown = testScope.tearDown || null;
                                  ^^^^^^^^

../../ui/webui/resources/js/webui_resource_test.js:256: ERROR - Property runTests never defined on Window
exports.runTests = runTests;
        ^^^^^^^^

../../ui/webui/resources/js/webui_resource_test.js:257: ERROR - Property endTests never defined on Window
exports.endTests = endTests;
        ^^^^^^^^

../../ui/webui/resources/js/webui_resource_test.js:261: ERROR - Property endTests never defined on Window
  window.endTests(false);
         ^^^^^^^^

7 error(s), 0 warning(s), 91.8% typed


 
Seems strictCheckTypes is also some "new direction" for the compiler, since some type inference features have been getting rolled back? - https://github.com/google/closure-compiler/wiki/%5BOBSOLETE%5D-Using-NTI-(new-type-inference)
Project Member

Comment 2 by bugdroid1@chromium.org, Sep 12

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d175b27a512129a212c4744357bc7f5c29ad8bf2

commit d175b27a512129a212c4744357bc7f5c29ad8bf2
Author: Trent Apted <tapted@chromium.org>
Date: Wed Sep 12 23:16:02 2018

Allow strictCheckTypes when using webui_resource_test.js and its assert.js.

strictCheckTypes warns when reading and assigning undocumented properties.
This is particularly useful when refactoring since otherwise removing
a property form an API does not always result in an error.

This CL documents setUp,setUpPage,tearDown,runTests,endTests, and
traceAssertionsForTesting.

Bug: 882739
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Icfddf0383301e318890f3e039bf7923d2b237f67
Reviewed-on: https://chromium-review.googlesource.com/1218267
Reviewed-by: calamity <calamity@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590851}
[modify] https://crrev.com/d175b27a512129a212c4744357bc7f5c29ad8bf2/ui/webui/resources/js/assert.js
[modify] https://crrev.com/d175b27a512129a212c4744357bc7f5c29ad8bf2/ui/webui/resources/js/webui_resource_test.js

Sign in to add a comment