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 2017Status: Duplicate (was: Available)