Skip to content

🏗🚮 Remove AmpPass.java#24047

Merged
rsimha merged 5 commits intoampproject:masterfrom
rsimha:2019-08-19-AmpPass
May 1, 2020
Merged

🏗🚮 Remove AmpPass.java#24047
rsimha merged 5 commits intoampproject:masterfrom
rsimha:2019-08-19-AmpPass

Conversation

@rsimha
Copy link
Copy Markdown
Contributor

@rsimha rsimha commented Aug 19, 2019

Now that assert* calls are eliminated via babel transforms, we no longer need the custom code in AmpPass.java.

This PR deletes AmpPass.java and cleans up its associated code so that the removal of assert* calls is done entirely via transforms.

Follow up to #24028, #23377, #26357, and #28127
Fixes #17120
Fixes #23960

@rsimha rsimha self-assigned this Aug 19, 2019
@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Aug 22, 2019

@jridgewell @erwinmombay This PR increases the size of v0.js by half a kilobyte. This means babel isn't doing everything that AmpPass.java was doing. What else must we do before this PR can be merged?

@jridgewell
Copy link
Copy Markdown
Contributor

It's probably the new errors we're leaving in?

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Aug 22, 2019

It's probably the new errors we're leaving in?

Should these be removed by babel?

Or are we okay with the half KB size increase? (If so, can you approve this PR for bundle-size?)

@jridgewell
Copy link
Copy Markdown
Contributor

What's the diff we're getting? If it's just the errors, then it's fine.

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Aug 22, 2019

What's the diff we're getting? If it's just the errors, then it's fine.

Yep, just the error strings. Edit: Generated more readable diffs below. There are a few more than I initially thought.

Before: v0-master.js
After: v0-remove-amppass.js
Diff: v0.diff

@erwinmombay
Copy link
Copy Markdown
Member

erwinmombay commented Aug 26, 2019

It looks like its still the issue I had mentioned before, where leaving the bare string literals as expression statements (when we remove the assertion in babel) does not get stripped by CC. so theres stuff like "Viewer", and "Resources" strings scattered all around. Maybe as a work around we could have a post process transform to clean it up?

@erwinmombay
Copy link
Copy Markdown
Member

Oh right, I guess we could also remove the raw strings just in the new code @jridgewell had implemented.

@jridgewell
Copy link
Copy Markdown
Contributor

I'm looking into what we need to enable in Closure to get it to DCE useless expressions.

@erwinmombay
Copy link
Copy Markdown
Member

@jridgewell setting "fold constants" on seems to get rid of the strings

@jridgewell
Copy link
Copy Markdown
Contributor

I can't figure out Closure, so I took care of it in Babel.

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Sep 5, 2019

@jridgewell setting "fold constants" on seems to get rid of the strings

@erwinmombay I tried this locally by adding options.setFoldConstants(true) to AmpCommandLineRunner.java, but the strings still remain. Were you able to get it to work with that option?

@erwinmombay
Copy link
Copy Markdown
Member

@rsimha no not with the jar we build and with our specific settings. what's weird is that @jridgewell had mentioned this DCE feature should be enabled even with just the simple optimizations.

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Sep 9, 2019

I've reopened #23960 to track the DCE fix. Once it's in, I'll rebase the original version of this PR.

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Dec 27, 2019

Dusting off this old PR. I've rebased it on the latest changes from master. With the commits introduced by @jridgewell, the diffs in v0.js are as follows.

@erwinmombay @jridgewell Could you review again, and comment on whether the changes to v0.js are acceptable, and if not, what is left to be done before we can get rid of AmpPass.java?

diff --git a/v0-master.js b/v0-remove-amppass.js
index 56f5cd0..ff464b3 100644
--- a/v0-master.js
+++ b/v0-remove-amppass.js
@@ -1506,7 +1506,7 @@ function $isInAmpdocFieExperiment$$module$src$ampdoc_fie$$($win$jscomp$46$$) {
 }
 function $installServiceInEmbedScope$$module$src$service$$($embedWin$$, $id$jscomp$9$$, $service$$) {
   var $topWin$jscomp$1$$ = $getTopWindow$$module$src$service$$($embedWin$$);
-  $isServiceRegistered$$module$src$service$$($embedWin$$, $id$jscomp$9$$);
+  !$isServiceRegistered$$module$src$service$$($embedWin$$, $id$jscomp$9$$);
   if ($isInAmpdocFieExperiment$$module$src$ampdoc_fie$$($topWin$jscomp$1$$)) {
     var $ampdoc$$ = $getAmpdoc$$module$src$service$$($embedWin$$.document);
     $registerServiceInternal$$module$src$service$$($getAmpdocServiceHolder$$module$src$service$$($ampdoc$$), $ampdoc$$, $id$jscomp$9$$, function() {
@@ -2799,7 +2799,7 @@ $JSCompiler_prototypeAlias$$.execute = function($invocation$jscomp$1_target$jsco
 };
 $JSCompiler_prototypeAlias$$.installActionHandler = function($target$jscomp$97$$, $handler$jscomp$9$$) {
   var $targetId$$ = $target$jscomp$97$$.getAttribute("id") || "";
-  "amp-" === $targetId$$.substring(0, 4) || $target$jscomp$97$$.tagName.toLowerCase();
+  "amp-" === $targetId$$.substring(0, 4) || $target$jscomp$97$$.tagName.toLowerCase() in $NON_AMP_ELEMENTS_ACTIONS_$$module$src$service$action_impl$$;
   if ($target$jscomp$97$$.__AMP_ACTION_HANDLER__) {
     $dev$$module$src$log$$().error("Action", "Action handler already installed for " + $target$jscomp$97$$);
   } else {
@@ -2954,6 +2954,9 @@ function $DeferredEvent$$module$src$service$action_impl$$($event$jscomp$25$$) {
   }
 }
 function $notImplemented$$module$src$service$action_impl$$() {
+  (function() {
+    throw Error("static assertion failure");
+  })();
 }
 function $parseActionMap$$module$src$service$action_impl$$($action$jscomp$8$$, $actionMap$jscomp$2_context$jscomp$2$$) {
   var $assertAction$$ = $assertActionForParser$$module$src$service$action_impl$$.bind(null, $action$jscomp$8$$, $actionMap$jscomp$2_context$jscomp$2$$), $assertToken$$ = $assertTokenForParser$$module$src$service$action_impl$$.bind(null, $action$jscomp$8$$, $actionMap$jscomp$2_context$jscomp$2$$);
@@ -4726,7 +4729,9 @@ function $ElementStub$$module$src$element_stub$$($element$jscomp$106$$) {
 }
 $$jscomp$inherits$$($ElementStub$$module$src$element_stub$$, $BaseElement$$module$src$base_element$$);
 $ElementStub$$module$src$element_stub$$.prototype.getLayoutPriority = function() {
-  return 0;
+  return function() {
+    throw Error("static assertion failure");
+  }();
 };
 $ElementStub$$module$src$element_stub$$.prototype.isLayoutSupported = function() {
   return !0;
@@ -5694,6 +5699,7 @@ function $createBaseCustomElementClass$$module$src$custom_element$$($win$jscomp$
   };
   $BaseCustomElement$$.prototype.$tryUpgrade_$ = function() {
     var $BaseCustomElement$$ = this, $htmlElement$jscomp$2$$ = this.implementation_;
+    !($htmlElement$jscomp$2$$ instanceof $ElementStub$$module$src$element_stub$$);
     if (1 == this.$upgradeState_$) {
       this.$upgradeState_$ = 4;
       var $startTime$jscomp$9$$ = $win$jscomp$165$$.Date.now(), $res$jscomp$12$$ = $htmlElement$jscomp$2$$.upgradeCallback();
@@ -7795,13 +7801,13 @@ $JSCompiler_prototypeAlias$$.get = function($name$jscomp$128$$) {
   return this.$replacements_$[$name$jscomp$128$$];
 };
 $JSCompiler_prototypeAlias$$.set = function($varName$jscomp$1$$, $syncResolver$$) {
-  $varName$jscomp$1$$.indexOf("RETURN");
+  -1 == $varName$jscomp$1$$.indexOf("RETURN");
   this.$replacements_$[$varName$jscomp$1$$] = this.$replacements_$[$varName$jscomp$1$$] || {sync:void 0, async:void 0};
   this.$replacements_$[$varName$jscomp$1$$].sync = $syncResolver$$;
   return this;
 };
 $JSCompiler_prototypeAlias$$.setAsync = function($varName$jscomp$2$$, $asyncResolver$$) {
-  $varName$jscomp$2$$.indexOf("RETURN");
+  -1 == $varName$jscomp$2$$.indexOf("RETURN");
   this.$replacements_$[$varName$jscomp$2$$] = this.$replacements_$[$varName$jscomp$2$$] || {sync:void 0, async:void 0};
   this.$replacements_$[$varName$jscomp$2$$].async = $asyncResolver$$;
   return this;
@@ -8377,7 +8383,7 @@ $JSCompiler_prototypeAlias$$.expandInputValueSync = function($element$jscomp$183
   return $JSCompiler_StaticMethods_expandInputValue_$$(this, $element$jscomp$183$$, !0);
 };
 function $JSCompiler_StaticMethods_expandInputValue_$$($JSCompiler_StaticMethods_expandInputValue_$self_result$jscomp$9$$, $element$jscomp$184$$, $opt_sync$jscomp$1$$) {
-  "INPUT" == $element$jscomp$184$$.tagName && ($element$jscomp$184$$.getAttribute("type") || "").toLowerCase();
+  "INPUT" == $element$jscomp$184$$.tagName && "hidden" == ($element$jscomp$184$$.getAttribute("type") || "").toLowerCase();
   var $whitelist$jscomp$2$$ = $JSCompiler_StaticMethods_getWhitelistForElement_$$($element$jscomp$184$$);
   if (!$whitelist$jscomp$2$$) {
     return $opt_sync$jscomp$1$$ ? $element$jscomp$184$$.value : Promise.resolve($element$jscomp$184$$.value);
@@ -10772,7 +10778,9 @@ $JSCompiler_prototypeAlias$$.dispose = function() {
   });
 };
 $JSCompiler_prototypeAlias$$.isSingleDoc = function() {
-  return null;
+  return function() {
+    throw Error("static assertion failure");
+  }();
 };
 $JSCompiler_prototypeAlias$$.getParent = function() {
   return this.$parent_$;
@@ -10794,27 +10802,41 @@ $JSCompiler_prototypeAlias$$.declareExtension = function($extensionId$jscomp$21$
   this.declaresExtension($extensionId$jscomp$21$$) || this.$declaredExtensions_$.push($extensionId$jscomp$21$$);
 };
 $JSCompiler_prototypeAlias$$.getRootNode = function() {
-  return null;
+  return function() {
+    throw Error("static assertion failure");
+  }();
 };
 $JSCompiler_prototypeAlias$$.getHeadNode = function() {
 };
 $JSCompiler_prototypeAlias$$.isBodyAvailable = function() {
-  return !1;
+  return function() {
+    throw Error("static assertion failure");
+  }();
 };
 $JSCompiler_prototypeAlias$$.getBody = function() {
-  return null;
+  return function() {
+    throw Error("static type assertion failure");
+  }();
 };
 $JSCompiler_prototypeAlias$$.waitForBodyOpen = function() {
-  return null;
+  return function() {
+    throw Error("static assertion failure");
+  }();
 };
 $JSCompiler_prototypeAlias$$.isReady = function() {
-  return null;
+  return function() {
+    throw Error("static assertion failure");
+  }();
 };
 $JSCompiler_prototypeAlias$$.whenReady = function() {
-  return null;
+  return function() {
+    throw Error("static assertion failure");
+  }();
 };
 $JSCompiler_prototypeAlias$$.getUrl = function() {
-  return null;
+  return function() {
+    throw Error("static type assertion failure");
+  }();
 };
 $JSCompiler_prototypeAlias$$.getElementById = function($id$jscomp$45$$) {
   return this.getRootNode().getElementById($id$jscomp$45$$);

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Dec 27, 2019

@jridgewell Looks like the babel plugin changes you added need accompanying fixes to the tests: https://travis-ci.org/ampproject/amphtml/jobs/630090177#L395-L630.

Edit: Done in 427e6bf.

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Jan 9, 2020

@jridgewell I think your babel changes are altering the return types of some of the assert functions to include null (scroll past the warnings to the errors). Any idea what needs to be done to fix these?

$ gulp check-types
[19:15:47] Using gulpfile ~/src/amphtml/gulpfile.js
[19:15:47] Starting 'check-types'...
[19:15:48] All packages in node_modules are up to date.
[19:15:48] Running check-types. Press Ctrl + C to cancel...
[19:15:48] Performing pre-closure babel transforms in /tmp/d2d169935522ca904efc55a42b08c9f0
..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

[19:16:15] Recompiled all CSS files into build/ (2.703 s)
[19:16:19] Generated custom closure compiler build-system/runner/dist/2114/runner.jar
[19:16:19] Started nailgun-server.jar on port 2114
[19:16:19] Checking types...
Type checking failed:
ads/google/a4a/utils.js:648: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the extern function call 'Array.isArray' is not being used.
    Array.isArray(analyticsConfig['url']);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ads/inabox/inabox-messaging-host.js:50: WARNING - [JSC_USELESS_CODE] Suspicious code. This code lacks side-effects. Is there a bug?
    if (key in this.map_) {
    ^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-a4a/0.1/signature-verifier.js:333: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'eq' operator is not being used.
      response.headers.get('Content-Type') == 'application/jwk-set+json';
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-accordion/0.1/amp-accordion.js:219: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
      parseJson( /** @type {string} */(sessionStr)) :
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-ad-network-doubleclick-impl/0.1/amp-ad-network-doubleclick-impl.js:498: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'not' operator is not being used.
    !isCdnProxy(this.win);
    ^^^^^^^^^^^^^^^^^^^^^

extensions/amp-ad/0.1/amp-ad-3p-impl.js:339: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    this.iframeLayoutBox_;
    ^^^^^^^^^^^^^^^^^^^^^

extensions/amp-analytics/0.1/config.js:101: WARNING - [JSC_UNREACHABLE_CODE] unreachable code
    if (!true) {
               ^

extensions/amp-analytics/0.1/transport.js:271: WARNING - [JSC_USELESS_CODE] Suspicious code. This code lacks side-effects. Is there a bug?
    if (result) {
    ^^^^^^^^^^^^^

extensions/amp-analytics/0.1/transport.js:298: WARNING - [JSC_USELESS_CODE] Suspicious code. This code lacks side-effects. Is there a bug?
      if (xhr.readyState == 4) {
      ^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-analytics/0.1/vendors.js:277: WARNING - [JSC_UNREACHABLE_CODE] unreachable code
if (!true) {
           ^

extensions/amp-analytics/0.1/visibility-manager-for-mapp.js:112: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
      this.intersectionRect_);
      ^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-consent/0.1/amp-consent.js:654: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    this.consentConfig_);
    ^^^^^^^^^^^^^^^^^^^

extensions/amp-form/0.1/amp-form-textarea.js:81: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    this.win_ = /** @type {!Window} */this.doc_.defaultView;
                                      ^^^^^^^^^^^^^^^^^^^^^

extensions/amp-form/0.1/amp-form-textarea.js:253: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
  element.ownerDocument.defaultView;
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-form/0.1/amp-form-textarea.js:319: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
  const doc = /** @type {!Document} */textarea.ownerDocument;
                                      ^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-form/0.1/amp-form-textarea.js:320: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
  const win = /** @type {!Window} */doc.defaultView;
                                    ^^^^^^^^^^^^^^^

extensions/amp-form/0.1/amp-form-textarea.js:321: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
  const body = /** @type {!HTMLBodyElement} */doc.body;
                                              ^^^^^^^^

extensions/amp-fx-collection/0.1/amp-fx-collection.js:85: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'not' operator is not being used.
    !this.seen_.includes(element);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-fx-collection/0.1/providers/amp-fx-presets.js:45: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'eq' operator is not being used.
  Math.abs(coeff) == 1;
  ^^^^^^^^^^^^^^^^^^^^

extensions/amp-fx-collection/0.1/providers/amp-fx-presets.js:116: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'eq' operator is not being used.
  Math.abs(coeff) == 1;
  ^^^^^^^^^^^^^^^^^^^^

extensions/amp-fx-collection/0.1/providers/fx-provider.js:85: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
      /** @type {!ScrollTogglePosition} */position);
                                          ^^^^^^^^

extensions/amp-iframe/0.1/amp-iframe.js:362: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    this.iframeLayoutBox_;
    ^^^^^^^^^^^^^^^^^^^^^

extensions/amp-lightbox/0.1/amp-lightbox.js:746: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    /** @type {!HTMLBodyElement} */document.body);
                                   ^^^^^^^^^^^^^

extensions/amp-recaptcha-input/0.1/amp-recaptcha-service.js:160: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
      /** @type {string} */this.recaptchaFrameOrigin_,
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-story/0.1/amp-story-share.js:242: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
      this.ampdoc_);
      ^^^^^^^^^^^^

extensions/amp-story/0.1/animation.js:316: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    this.runner_;
    ^^^^^^^^^^^^

extensions/amp-story/1.0/animation.js:346: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    this.runner_;
    ^^^^^^^^^^^^

extensions/amp-story/1.0/pagination-buttons.js:333: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
      this.backButtonStateToRestore_);
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-story/1.0/pagination-buttons.js:338: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
      this.forwardButtonStateToRestore_);
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-subscriptions/0.1/local-subscription-platform-remote.js:109: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    this.pingbackUrl_;
    ^^^^^^^^^^^^^^^^^

extensions/amp-video-docking/0.1/amp-video-docking.js:1584: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'eq' operator is not being used.
    Math.abs(direction) == 1;
    ^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-video-docking/0.1/amp-video-docking.js:1633: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'eq' operator is not being used.
    Math.abs(direction) == 1;
    ^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-video/0.1/amp-video.js:403: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'not' operator is not being used.
      !this.isCachedByCDN_(source);
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-web-push/0.1/window-messenger.js:133: WARNING - [JSC_USELESS_CODE] Suspicious code. This code lacks side-effects. Is there a bug?
      if (this.debug_) {
      ^^^^^^^^^^^^^^^^^^

extensions/amp-web-push/0.1/window-messenger.js:188: WARNING - [JSC_USELESS_CODE] Suspicious code. This code lacks side-effects. Is there a bug?
    if (this.debug_) {
    ^^^^^^^^^^^^^^^^^^

extensions/amp-web-push/0.1/window-messenger.js:314: WARNING - [JSC_USELESS_CODE] Suspicious code. This code lacks side-effects. Is there a bug?
    if (this.debug_) {
    ^^^^^^^^^^^^^^^^^^

extensions/amp-web-push/0.1/window-messenger.js:367: WARNING - [JSC_USELESS_CODE] Suspicious code. This code lacks side-effects. Is there a bug?
      if (this.debug_) {
      ^^^^^^^^^^^^^^^^^^

extensions/amp-web-push/0.1/window-messenger.js:384: WARNING - [JSC_USELESS_CODE] Suspicious code. This code lacks side-effects. Is there a bug?
      if (this.debug_) {
      ^^^^^^^^^^^^^^^^^^

extensions/amp-web-push/0.1/window-messenger.js:484: WARNING - [JSC_USELESS_CODE] Suspicious code. This code lacks side-effects. Is there a bug?
    if (this.debug_) {
    ^^^^^^^^^^^^^^^^^^

src/css.js:120: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'sheq' operator is not being used.
  escaped.indexOf(')') === -1;
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/custom-element.js:901: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'not' operator is not being used.
      !isStub(impl);
      ^^^^^^^^^^^^^

src/layout.js:347: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    parseLayout(completedLayoutAttr);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/service.js:115: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'not' operator is not being used.
  !isServiceRegistered(embedWin, id);
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/service/action-impl.js:467: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'in' operator is not being used.
    target.tagName.toLowerCase() in NON_AMP_ELEMENTS_ACTIONS_;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/service/hidden-observer-impl.js:54: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
    this.win_ = /** @type {!Window} */doc.defaultView;
                                      ^^^^^^^^^^^^^^^

src/service/resource.js:93: WARNING - [JSC_MISPLACED_ANNOTATION] Misplaced type annotation. Type annotations are not allowed here. Are you missing parentheses?
      Resource.forElementOptional(element));
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/service/url-replacements-impl.js:997: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'eq' operator is not being used.
    (element.getAttribute('type') || '').toLowerCase() == 'hidden';
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/service/variable-source.js:230: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'eq' operator is not being used.
    varName.indexOf('RETURN') == -1;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/service/variable-source.js:250: WARNING - [JSC_USELESS_CODE] Suspicious code. The result of the 'eq' operator is not being used.
    varName.indexOf('RETURN') == -1;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-3d-gltf/0.1/amp-3d-gltf.js:157: ERROR - [JSC_TYPE_MISMATCH] assignment to property unlistenMessage_ of Amp3dGltf
found   : (function(): ?|undefined)
required: (Function|null)
    this.unlistenMessage_ = this.listenGltfViewerMessages_();
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-accordion/0.1/amp-accordion.js:217: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (JsonObject|null)
required: JsonObject
      return sessionStr ?
             ^^^^^^^^^^^^

extensions/amp-ad-exit/0.1/amp-ad-exit.js:318: ERROR - [JSC_TYPE_MISMATCH] actual parameter 3 of Array.prototype.splice does not match formal parameter
found   : (Filter$$module$extensions$amp_ad_exit$0_1$filters$filter|undefined)
required: Filter$$module$extensions$amp_ad_exit$0_1$filters$filter
        createFilter(
        ^^^^^^^^^^^^^

extensions/amp-ad-network-adsense-impl/0.1/amp-ad-network-adsense-impl.js:471: ERROR - [JSC_TYPE_MISMATCH] actual parameter 2 of Navigation$$module$src$service$navigation.installAnchorClickInterceptor does not match formal parameter
found   : (Window|null)
required: Window
      this.iframe.contentWindow);
      ^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-ad-network-doubleclick-impl/0.1/amp-ad-network-doubleclick-impl.js:1056: ERROR - [JSC_TYPE_MISMATCH] actual parameter 2 of Navigation$$module$src$service$navigation.installAnchorClickInterceptor does not match formal parameter
found   : (Window|null)
required: Window
      this.iframe.contentWindow);
      ^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-ad/0.1/amp-ad-3p-impl.js:341: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of moveLayoutRect$$module$src$layout_rect does not match formal parameter
found   : (null|{
  bottom: number,
  height: number,
  left: number,
  right: number,
  top: number,
  width: number,
  x: number,
  y: number
})
required: {
  bottom: number,
  height: number,
  left: number,
  right: number,
  top: number,
  width: number,
  x: number,
  y: number
}
    return moveLayoutRect(iframe, box.left, box.top);
                          ^^^^^^

extensions/amp-analytics/0.1/visibility-manager-for-mapp.js:112: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (null|{
  bottom: number,
  height: number,
  left: number,
  right: number,
  top: number,
  width: number,
  x: number,
  y: number
})
required: {
  bottom: number,
  height: number,
  left: number,
  right: number,
  top: number,
  width: number,
  x: number,
  y: number
}
      this.intersectionRect_);
      ^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-autocomplete/0.1/amp-autocomplete.js:569: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of AutocompleteBindingDef$$module$extensions$amp_autocomplete$0_1$autocomplete_binding_def.prototype.shouldAutocomplete does not match formal parameter
found   : Element
required: HTMLInputElement
    this.binding_.shouldAutocomplete( /** @type {!Element} */(this.inputElement_)))
                                                             ^^^^^^^^^^^^^^^^^^^^

extensions/amp-autocomplete/0.1/amp-autocomplete.js:588: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of AutocompleteBindingDef$$module$extensions$amp_autocomplete$0_1$autocomplete_binding_def.prototype.getUserInputForUpdate does not match formal parameter
found   : Element
required: HTMLInputElement
    this.userInput_ = this.binding_.getUserInputForUpdate( /** @type {!Element} */(
                                                                                  ^

extensions/amp-autocomplete/0.1/amp-autocomplete.js:1076: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of AutocompleteBindingDef$$module$extensions$amp_autocomplete$0_1$autocomplete_binding_def.prototype.displayActiveItemInInput does not match formal parameter
found   : Element
required: HTMLInputElement
    this.binding_.displayActiveItemInInput( /** @type {!Element} */(
                                                                   ^

extensions/amp-autocomplete/0.1/amp-autocomplete.js:1138: ERROR - [JSC_TYPE_MISMATCH] actual parameter 2 of AutocompleteBindingDef$$module$extensions$amp_autocomplete$0_1$autocomplete_binding_def.prototype.resetInputOnWrapAround does not match formal parameter
found   : Element
required: HTMLInputElement
    this.userInput_, /** @type {!Element} */(
                                            ^

extensions/amp-base-carousel/0.1/amp-base-carousel.js:582: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of isRTL$$module$src$dom does not match formal parameter
found   : (Document|null)
required: Document
    const rtl = isRTL(this.element.ownerDocument);
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-carousel/0.2/amp-carousel.js:159: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of ChildLayoutManager$$module$extensions$amp_base_carousel$0_1$child_layout_manager does not match formal parameter
found   : {
  ampElement: AMP.BaseElement,
  intersectionElement: (Element|null),
  intersectionThreshold: (number|undefined),
  nearbyMarginInPercent: (number|undefined),
  viewportIntersectionCallback: (function(Element, boolean): ?|undefined),
  viewportIntersectionThreshold: (number|undefined)
}
required: {
  ampElement: AMP.BaseElement,
  intersectionElement: Element,
  intersectionThreshold: (number|undefined),
  nearbyMarginInPercent: (number|undefined),
  viewportIntersectionCallback: (function(Element, boolean): ?|undefined),
  viewportIntersectionThreshold: (number|undefined)
}
missing : []
mismatch: [intersectionElement]
    this.childLayoutManager_ = new ChildLayoutManager({
                                                      ^

extensions/amp-carousel/0.2/amp-carousel.js:278: ERROR - [JSC_TYPE_MISMATCH] actual parameter 2 of computedStyle$$module$src$style does not match formal parameter
found   : (Element|null)
required: Element
    const _computedStyle = computedStyle(this.win, el),direction = _computedStyle.direction,_foo4 = void 0;
                                                   ^^

extensions/amp-consent/0.1/amp-consent.js:654: ERROR - [JSC_TYPE_MISMATCH] actual parameter 2 of ConsentUI$$module$extensions$amp_consent$0_1$consent_ui does not match formal parameter
found   : (JsonObject|null)
required: JsonObject
    this.consentConfig_);
    ^^^^^^^^^^^^^^^^^^^

extensions/amp-experiment/0.1/amp-experiment.js:92: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (JsonObject|null)
required: JsonObject
    return parseJson(children[0].textContent);
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-experiment/1.0/amp-experiment.js:178: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (JsonObject|null)
required: JsonObject
    return parseJson(children[0].textContent);
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-form/0.1/amp-form-textarea.js:127: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of throttle$$module$src$utils$rate_limit does not match formal parameter
found   : (Window|null)
required: Window
    this.win_,
    ^^^^^^^^^

extensions/amp-form/0.1/amp-form-textarea.js:269: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of computedStyle$$module$src$style does not match formal parameter
found   : (Window|null)
required: Window
    const computed = computedStyle(win, element);
                                   ^^^

extensions/amp-form/0.1/amp-form-textarea.js:333: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of MutatorInterface$$module$src$service$mutator_interface.prototype.measureMutateElement does not match formal parameter
found   : (HTMLBodyElement|null)
required: Element
  body,
  ^^^^

extensions/amp-form/0.1/amp-form-textarea.js:335: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of computedStyle$$module$src$style does not match formal parameter
found   : (Window|null)
required: Window
    const computed = computedStyle(win, textarea);
                                   ^^^

extensions/amp-form/0.1/amp-form-textarea.js:358: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of MutatorInterface$$module$src$service$mutator_interface.prototype.measureMutateElement does not match formal parameter
found   : (HTMLBodyElement|null)
required: Element
    body,
    ^^^^

extensions/amp-fx-collection/0.1/providers/fx-provider.js:85: ERROR - [JSC_TYPE_MISMATCH] actual parameter 3 of scrollToggle$$module$extensions$amp_fx_collection$0_1$providers$fx_provider does not match formal parameter
found   : (ScrollTogglePosition$$module$extensions$amp_fx_collection$0_1$scroll_toggle<string>|null)
required: ScrollTogglePosition$$module$extensions$amp_fx_collection$0_1$scroll_toggle<string>
      /** @type {!ScrollTogglePosition} */position);
                                          ^^^^^^^^

extensions/amp-iframe/0.1/amp-iframe.js:364: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of moveLayoutRect$$module$src$layout_rect does not match formal parameter
found   : (null|{
  bottom: number,
  height: number,
  left: number,
  right: number,
  top: number,
  width: number,
  x: number,
  y: number
})
required: {
  bottom: number,
  height: number,
  left: number,
  right: number,
  top: number,
  width: number,
  x: number,
  y: number
}
    return moveLayoutRect(iframe, box.left, box.top);
                          ^^^^^^

extensions/amp-iframe/0.1/amp-iframe.js:434: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of makePausable$$module$src$iframe_helper does not match formal parameter
found   : (HTMLIFrameElement|null)
required: HTMLIFrameElement
      makePausable(this.iframe_);
                   ^^^^^^^^^^^^

extensions/amp-iframe/0.1/amp-iframe.js:501: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of setPaused$$module$src$iframe_helper does not match formal parameter
found   : (HTMLIFrameElement|null)
required: HTMLIFrameElement
      setPaused(this.iframe_, true);
                ^^^^^^^^^^^^

extensions/amp-iframe/0.1/amp-iframe.js:508: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of setPaused$$module$src$iframe_helper does not match formal parameter
found   : (HTMLIFrameElement|null)
required: HTMLIFrameElement
      setPaused(this.iframe_, false);
                ^^^^^^^^^^^^

extensions/amp-inline-gallery/0.1/amp-inline-gallery-pagination.js:192: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of scopedQuerySelectorAll$$module$src$dom does not match formal parameter
found   : (Element|null)
required: Element
    this.paginationDots_,
    ^^^^^^^^^^^^^^^^^^^^

extensions/amp-lightbox-gallery/0.1/amp-lightbox-gallery.js:320: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of Node.prototype.appendChild does not match formal parameter
found   : *
required: (Node|null)
        imageViewer.appendChild(clonedNode);
                                ^^^^^^^^^^

extensions/amp-lightbox-gallery/0.1/amp-lightbox-gallery.js:325: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of Node.prototype.appendChild does not match formal parameter
found   : *
required: (Node|null)
      this.carousel_.appendChild(slide);
                                 ^^^^^

extensions/amp-list/0.1/amp-list.js:1101: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of getLayoutClass$$module$src$layout does not match formal parameter
found   : (Layout$$module$src$layout<string>|undefined)
required: Layout$$module$src$layout<string>
    const layoutClass = getLayoutClass(layout);
                                       ^^^^^^

extensions/amp-next-page/0.1/next-page-service.js:236: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of installStylesForDoc$$module$src$style_installer does not match formal parameter
found   : (AmpDoc$$module$src$service$ampdoc_impl|undefined)
required: AmpDoc$$module$src$service$ampdoc_impl
    installStylesForDoc(ampdoc, CSS, null, false, TAG);
                        ^^^^^^

extensions/amp-next-page/0.2/service.js:327: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of installStylesForDoc$$module$src$style_installer does not match formal parameter
found   : (AmpDoc$$module$src$service$ampdoc_impl|undefined)
required: AmpDoc$$module$src$service$ampdoc_impl
      installStylesForDoc(ampdoc, CSS, null, false, TAG);
                          ^^^^^^

extensions/amp-recaptcha-input/0.1/amp-recaptcha-service.js:160: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of AmpRecaptchaService$$module$extensions$amp_recaptcha_input$0_1$amp_recaptcha_service.prototype.postMessageToIframe_ does not match formal parameter
found   : (null|string)
required: string
      /** @type {string} */this.recaptchaFrameOrigin_,
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-sidebar/0.1/amp-sidebar.js:287: ERROR - [JSC_TYPE_MISMATCH] actual parameter 4 of ActionService$$module$src$service$action_impl.prototype.hasResolvableActionForTarget does not match formal parameter
found   : (Element|null)
required: (Element|undefined)
      candidate.parentElement);
      ^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-sidebar/0.1/amp-sidebar.js:411: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of tryFocus$$module$src$dom does not match formal parameter
found   : (Element|null)
required: Element
      tryFocus(this.closeButton_);
               ^^^^^^^^^^^^^^^^^

extensions/amp-sidebar/0.2/amp-sidebar.js:293: ERROR - [JSC_TYPE_MISMATCH] actual parameter 4 of ActionService$$module$src$service$action_impl.prototype.hasResolvableActionForTarget does not match formal parameter
found   : (Element|null)
required: (Element|undefined)
      candidate.parentElement);
      ^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-sidebar/0.2/amp-sidebar.js:418: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of tryFocus$$module$src$dom does not match formal parameter
found   : (Element|null)
required: Element
      tryFocus(this.closeButton_);
               ^^^^^^^^^^^^^^^^^

extensions/amp-story-auto-ads/0.1/amp-story-auto-ads.js:397: ERROR - [JSC_TYPE_MISMATCH] actual parameter 5 of StoryAdPage$$module$extensions$amp_story_auto_ads$0_1$story_ad_page does not match formal parameter
found   : (ButtonTextFitter$$module$extensions$amp_story_auto_ads$0_1$story_ad_button_text_fitter|null)
required: ButtonTextFitter$$module$extensions$amp_story_auto_ads$0_1$story_ad_button_text_fitter
    this.buttonFitter_);
    ^^^^^^^^^^^^^^^^^^

extensions/amp-story/0.1/amp-story-consent.js:296: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of MutatorInterface$$module$src$service$mutator_interface.prototype.measureMutateElement does not match formal parameter
found   : (Element|null)
required: Element
    this.storyConsentEl_,
    ^^^^^^^^^^^^^^^^^^^^

extensions/amp-story/0.1/amp-story-share.js:242: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (AmpDoc$$module$src$service$ampdoc_impl|null)
required: AmpDoc$$module$src$service$ampdoc_impl
      this.ampdoc_);
      ^^^^^^^^^^^^

extensions/amp-story/0.1/animation.js:330: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of AnimationRunner$$module$extensions$amp_story$0_1$animation.prototype.startWhenReady_ does not match formal parameter
found   : (AnimationRunner$$module$extensions$amp_animation$0_1$runners$animation_runner|null)
required: AnimationRunner$$module$extensions$amp_animation$0_1$runners$animation_runner
          return this.startWhenReady_(runner);
                                      ^^^^^^

extensions/amp-story/0.1/animation.js:332: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of AnimationRunner$$module$extensions$amp_story$0_1$animation.prototype.finishWhenReady_ does not match formal parameter
found   : (AnimationRunner$$module$extensions$amp_animation$0_1$runners$animation_runner|null)
required: AnimationRunner$$module$extensions$amp_animation$0_1$runners$animation_runner
          return this.finishWhenReady_(runner);}
                                       ^^^^^^

extensions/amp-story/1.0/amp-story-share.js:265: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (AmpDoc$$module$src$service$ampdoc_impl|null)
required: AmpDoc$$module$src$service$ampdoc_impl
    return this.ampdoc_;
           ^^^^^^^^^^^^

extensions/amp-story/1.0/animation.js:360: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of AnimationRunner$$module$extensions$amp_story$1_0$animation.prototype.startWhenReady_ does not match formal parameter
found   : (AnimationRunner$$module$extensions$amp_animation$0_1$runners$animation_runner|null)
required: AnimationRunner$$module$extensions$amp_animation$0_1$runners$animation_runner
          return this.startWhenReady_(runner);
                                      ^^^^^^

extensions/amp-story/1.0/animation.js:362: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of AnimationRunner$$module$extensions$amp_story$1_0$animation.prototype.finishWhenReady_ does not match formal parameter
found   : (AnimationRunner$$module$extensions$amp_animation$0_1$runners$animation_runner|null)
required: AnimationRunner$$module$extensions$amp_animation$0_1$runners$animation_runner
          return this.finishWhenReady_(runner);}
                                       ^^^^^^

extensions/amp-story/1.0/pagination-buttons.js:333: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of PaginationButton$$module$extensions$amp_story$1_0$pagination_buttons.prototype.updateState does not match formal parameter
found   : (null|{className: string, triggers: (string|undefined)})
required: {className: string, triggers: (string|undefined)}
      this.backButtonStateToRestore_);
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-story/1.0/pagination-buttons.js:338: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of PaginationButton$$module$extensions$amp_story$1_0$pagination_buttons.prototype.updateState does not match formal parameter
found   : (null|{className: string, triggers: (string|undefined)})
required: {className: string, triggers: (string|undefined)}
      this.forwardButtonStateToRestore_);
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extensions/amp-story/1.0/progress-bar.js:442: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of removeChildren$$module$src$dom does not match formal parameter
found   : (Element|null)
required: Element
    removeChildren(this.root_);
                   ^^^^^^^^^^

extensions/amp-story/1.0/progress-bar.js:610: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of MutatorInterface$$module$src$service$mutator_interface.prototype.mutateElement does not match formal parameter
found   : (Element|null)
required: Element
    this.mutator_.mutateElement(progressEl, () => {
                                ^^^^^^^^^^

extensions/amp-story/1.0/progress-bar.js:619: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of setImportantStyles$$module$src$style does not match formal parameter
found   : (Element|null)
required: Element
      setImportantStyles(progressEl, {
                         ^^^^^^^^^^

extensions/amp-subscriptions/0.1/local-subscription-platform-remote.js:114: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of UrlBuilder$$module$extensions$amp_subscriptions$0_1$url_builder.prototype.buildUrl does not match formal parameter
found   : (null|string)
required: string
    pingbackUrl,
    ^^^^^^^^^^^

src/custom-element.js:332: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (AmpDoc$$module$src$service$ampdoc_impl|null)
required: AmpDoc$$module$src$service$ampdoc_impl
      return (/** @typedef {!./service/ampdoc-impl.AmpDoc} */this.ampdoc_);
                                                             ^^^^^^^^^^^^

src/custom-element.js:347: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (ResourcesInterface$$module$src$service$resources_interface|null)
required: ResourcesInterface$$module$src$service$resources_interface
      return (/** @typedef {!./service/resources-interface.ResourcesInterface} */this.
                                                                                 ^^^^^

src/layout.js:362: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (Layout$$module$src$layout<string>|undefined)
required: Layout$$module$src$layout<string>
    return layout;
           ^^^^^^

src/service.js:628: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of getAmpdocServiceHolder$$module$src$service does not match formal parameter
found   : (AmpDoc$$module$src$service$ampdoc_impl|null)
required: (AmpDoc$$module$src$service$ampdoc_impl|Node)
  getAmpdocServiceHolder(ampdoc.getParent()),
                         ^^^^^^^^^^^^^^^^^^

src/service/ampdoc-impl.js:115: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (AmpDoc$$module$src$service$ampdoc_impl|null)
required: AmpDoc$$module$src$service$ampdoc_impl
    return this.singleDoc_;
           ^^^^^^^^^^^^^^^

src/service/ampdoc-impl.js:286: ERROR - [JSC_TYPE_MISMATCH] actual parameter 1 of AmpDocService$$module$src$service$ampdoc_impl.prototype.getAmpDoc does not match formal parameter
found   : (HTMLIFrameElement|HTMLObjectElement|null)
required: Node
    this.getAmpDoc(frameElement),
                   ^^^^^^^^^^^^

src/service/ampdoc-impl.js:657: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (VisibilityState$$module$src$visibility_state<string>|null)
required: VisibilityState$$module$src$visibility_state<string>
    return this.visibilityState_;
           ^^^^^^^^^^^^^^^^^^^^^

src/service/hidden-observer-impl.js:54: ERROR - [JSC_TYPE_MISMATCH] assignment to property win_ of HiddenObserver
found   : (Window|null)
required: Window
    this.win_ = /** @type {!Window} */doc.defaultView;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/service/resource.js:93: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (Resource$$module$src$service$resource|null)
required: Resource$$module$src$service$resource
      Resource.forElementOptional(element));
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/service/viewer-impl.js:230: ERROR - [JSC_TYPE_MISMATCH] assignment to property resolvedViewerUrl_ of ViewerImpl
found   : (null|string)
required: string
            this.resolvedViewerUrl_ = viewerUrlOverride;
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/static-template.js:106: ERROR - [JSC_TYPE_MISMATCH] inconsistent return type
found   : (Element|null)
required: Element
  return el;
         ^^

63 error(s), 49 warning(s), 93.7% typed

[19:16:42] 'check-types' errored after 55 s
[19:16:42] Error in plugin 'gulp-google-closure-compiler'
Compilation errors occurred

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Jan 11, 2020

Sat down with @jridgewell and figured out what was missing. This PR is ready for another review.

@rsimha rsimha removed the Blocked label Jan 11, 2020
@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Jan 15, 2020

@jridgewell Just updated this PR with your suggested changes. At this point, the babel transform changes outnumber the Java changes I originally set out to make. So once we get this to a working condition, I think we should split off the babel changes into a new PR authored by you.

@jridgewell
Copy link
Copy Markdown
Contributor

I updated the PR. After normalizing for variable names, the input and output match perfectly except for the one getLengthUnits change.

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Apr 30, 2020

I updated the PR. After normalizing for variable names, the input and output match perfectly except for the one getLengthUnits change.

Nice work! Can confirm that the output is identical (modulo variable names and intentional code changes).

image

Once you're done fixing the lint errors and babel plugin tests, can you split off your additional commits into a separate PR, so they can be merged independent of this one?

@jridgewell
Copy link
Copy Markdown
Contributor

jridgewell commented Apr 30, 2020

#28127

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented Apr 30, 2020

@jridgewell Almost there, but not quite. I did a full gulp dist before / after removing AmpPass.java. While v0.js and most extensions are byte-for-byte identical, there are non-trivial diffs in these extensions, resulting in a bunch of integration test, visual-diff, and end-to-end test failures:

image

I had to add some additional casts / asserts to satisfy gulp check-types (4bb2938), which makes me believe there's an edge case being missed by the babel transforms. (Unless you think I've added a bad cast / assert somewhere?)

@jridgewell
Copy link
Copy Markdown
Contributor

jridgewell commented May 1, 2020

New commits. There are a few trivial differences, but it seems ok. Use npx gulp dist --pseudo_names --version_override 0000000000000 --sanatize_for_diff

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented May 1, 2020

Still seeing the same test failures: https://travis-ci.org/github/ampproject/amphtml/builds/681798587

Could it be the fault of the commit that fixes check-types? Edit: It's due to IS_DEV. Fixed.

Copy link
Copy Markdown
Contributor Author

@rsimha rsimha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bravo, yet again!

@rsimha
Copy link
Copy Markdown
Contributor Author

rsimha commented May 1, 2020

9 months and 40+ reviews later, this PR is ready to merge.

I've verified that there are zero diffs in v0.js (modulo mangled variable names) and a small number of expected diffs in other files due to small, intentional changes (#24047 (comment)).

Special thanks to @jridgwell and @erwinmombay for writing all the babel transforms that replace AmpPass.java, and to @jridgewell for all the debugging help.

Will wait for one final approval before merging.

@rsimha rsimha merged commit 3953658 into ampproject:master May 1, 2020
@rsimha rsimha deleted the 2019-08-19-AmpPass branch May 1, 2020 21:45
jridgewell added a commit to jridgewell/amphtml that referenced this pull request May 5, 2020
Matches `devAssert`'s change in ampproject#24047.
jridgewell added a commit that referenced this pull request May 5, 2020
* Fix userAssert's type annotation

Matches `devAssert`'s change in #24047.

* Remove old notes

* Add single cast

Closure is narrowing the type to `Object` due to the `typeof x === 'object'` check. Seems like a bug.

* Speed up check-types by 30s
ldoroshe pushed a commit to ldoroshe/amphtml that referenced this pull request May 8, 2020
ldoroshe pushed a commit to ldoroshe/amphtml that referenced this pull request May 8, 2020
* Fix userAssert's type annotation

Matches `devAssert`'s change in ampproject#24047.

* Remove old notes

* Add single cast

Closure is narrowing the type to `Object` due to the `typeof x === 'object'` check. Seems like a bug.

* Speed up check-types by 30s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not all assert calls are being removed from v0.js by babel transforms move away from custom closure passes and transformation

5 participants