From 5382e2ca1fa4dde9ac03d177e8f1c9d57b1d599e Mon Sep 17 00:00:00 2001 From: Laura Harker Date: Mon, 9 Sep 2019 16:38:51 -0700 Subject: [PATCH] Work around Closure Compiler bug to avoid upcoming type error Fixing a compiler type-equality bug uncovers a new error caused by https://github.com/google/closure-compiler/issues/2928. --- lib/utils/templatize.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/utils/templatize.js b/lib/utils/templatize.js index 4e42ae6fe1..60a2a8b104 100644 --- a/lib/utils/templatize.js +++ b/lib/utils/templatize.js @@ -392,21 +392,31 @@ function addPropagateEffects(target, templateInfo, options, methodHost) { * @constructor * @extends {DataTemplate} */ - let templatizedBase = options.mutableData ? MutableDataTemplate : DataTemplate; + let templatizedBase = + options.mutableData ? MutableDataTemplate : DataTemplate; + + // NOTE: due to https://github.com/google/closure-compiler/issues/2928, + // combining the next two lines into one assignment causes a spurious + // type error. + class TemplatizedTemplate extends templatizedBase {} /** @private */ - klass = templateInfo.templatizeTemplateClass = - class TemplatizedTemplate extends templatizedBase {}; + klass = templateInfo.templatizeTemplateClass = TemplatizedTemplate; } else { /** * @constructor * @extends {PolymerElement} */ const templatizedBase = target.constructor; + // Create a cached subclass of the base custom element class onto which // to put the template-specific propagate effects + // NOTE: due to https://github.com/google/closure-compiler/issues/2928, + // combining the next two lines into one assignment causes a spurious + // type error. + class TemplatizedTemplateExtension extends templatizedBase {} /** @private */ klass = templateInfo.templatizeTemplateClass = - class TemplatizedTemplateExtension extends templatizedBase {}; + TemplatizedTemplateExtension; } // Add template - >instances effects // and host <- template effects