Chrome Version : 71.0.3559.6
I keep running into type errors that aren't picked up by typechecking. The most common case seems to be for callback arguments. E.g.
something.getFoo(function(ihavenotype) {... });
these need to be documented like
something.getFoo(function /** ReturnType */ (/** TheType */ ihaveatype) {... });
see https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#param-type-varname-description
and https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#return-type-description
That's _if_ closure can't figure out the argument for itself. Often it already knows the type of a callback arg, but doesn't tell you.
There's jsdocMissingType, but it doesn't seem to do anything. The only way to catch these seems to be to compile with linkChecks, but that emits a bunch of stuff we don't care about like
../../ui/webui/resources/js/cr/event_target.js:23: WARNING - Missing semicolon
function EventTarget() {}
^^^^^^^^^^^^^^^^^^^^^^^^
(I think we even have a presubmit that ensures we _don't_ have a semicolon there?)
There's a ton of legitimate errors though. A whole bunch in third_party/jstemplate
It's probably not realistic to add jscomp_warning=lintChecks to default build args, but I'm making this bug to track work towards linting javascript in various bits of Chrome's codebase.
There are some other useful things we should probably add. I'm currently toying with
+ closure_flags = default_closure_args + [
+ "jscomp_error=misplacedTypeAnnotation",
+ "jscomp_error=jsdocMissingType",
+ "jscomp_error=functionParams",
+ "jscomp_error=unusedPrivateMembers",
+ "jscomp_error=unusedLocalVariables",
+ "jscomp_warning=lintChecks",
+ ]
Comment 1 by tapted@chromium.org
, Oct 24