New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 748263 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 421562
Owner: ----
Closed: Jul 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

Closure compilation: Invalid/Ignored type annotations exist in WebUI code

Project Member Reported by dpa...@chromium.org, Jul 24 2017

Issue description

For some reason our Closure compiler flags include the following flag
jscomp_off=misplacedTypeAnnotation

see [1] (there is a mention of an old crbug in the comment). This has caused various invalid/ignored type annotations to exist in the code, providing a false-sense of type coverage. For example see [2], where an anonymous function is supposedly annotated with @param.

Changing those lines to be obviously wrong, something like 
-----------
this.nativeLayer_.grantExtensionPrinterAccess(destination.id).then(
  /**
   * @param {TypeThatDoesNotExistAnywhere} destinationInfo 
   */
  function(destinationInfo) {
------------
still compiles successfully, since the annotations are completely ignored (they are not applied to any function).

Turning off jscomp_off=misplacedTypeAnnotation flag and recompiling, reveals a lot such cases (pasting just two examples from print_preview/ below)

## /usr/local/workspace/chromium1/src/chrome/browser/resources/print_preview/previewarea/preview_area.js:538: WARNING - Misplaced function annotation. This JSDoc is not attached to a function node. Are you missing parentheses?
##           function(previewUid) {
##           ^^^^^^^^^^^^^^^^^^^^^^
## 
## /usr/local/workspace/chromium1/src/chrome/browser/resources/print_preview/previewarea/preview_area.js:546: WARNING - Misplaced function annotation. This JSDoc is not attached to a function node. Are you missing parentheses?
##           function(type) {
##           ^^^^^^^^^^^^^^^^

We should probably figure out how to make these type annotations valid, or completely remove them (and remove the compiler flag too). FWIW, I discovered this problem as I am converting bind(this) to use ES6 arrow, which exhibits better type coverage, because the call to bind() causes the compiler to be more lenient. See minimal example at https://goo.gl/3Jcyby (click "Advanced" before compiling).


[1] https://cs.chromium.org/chromium/src/third_party/closure_compiler/closure_args.gypi?l=53,54
[2] https://cs.chromium.org/chromium/src/chrome/browser/resources/print_preview/data/destination_store.js?l=1021-1025
 

Comment 1 by dpa...@chromium.org, Jul 25 2017

Mergedinto: 421562
Status: Duplicate (was: Available)
My findings are already recorded at https://bugs.chromium.org/p/chromium/issues/detail?id=421562#c5. That bug has been closed, but it seems that there is more work to be done. Merging.

Sign in to add a comment