From 0b152938b37a0f3a144f04e9662c33928dabf1ff Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Thu, 27 Apr 2017 14:32:51 -0700 Subject: [PATCH] fix typing for Polymer.Element --- closure.log | 89 +------------------------------------------- polymer-element.html | 5 +++ 2 files changed, 6 insertions(+), 88 deletions(-) diff --git a/closure.log b/closure.log index 994df1c3d1..7a433851f3 100644 --- a/closure.log +++ b/closure.log @@ -645,10 +645,6 @@ Found : PolymerElement return super._parseTemplateContent(template, templateInfo, nodeInfo); ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -/polymer.html_script_11.js:862: WARNING - Type annotation references non-existent type Polymer.Element. - * @type {Array} - ^^^^^^^^^^^^^^^ - /polymer.html_script_11.js:870: WARNING - Property is never defined on prototype of type HTMLElement console.log('[' + prototype.is + ']: registered') ^^^^^^^^^^^^ @@ -768,41 +764,14 @@ Found : $polymer_html_script_26$classdecl$var2<|function(new:$polymer_html_sc this._flushProperties(); ^^^^^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:278: WARNING - Property disconnectedCallback never defined on domRepeatBase.prototype of type domRepeatBase.prototype - super.disconnectedCallback(); - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - /polymer.html_script_30.js:279: WARNING - Cannot add property __isDetached to a struct instance after it is constructed. this.__isDetached = true; ^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:286: WARNING - Property connectedCallback never defined on domRepeatBase.prototype of type domRepeatBase.prototype - super.connectedCallback(); - ^^^^^^^^^^^^^^^^^^^^^^^^^ - -/polymer.html_script_30.js:290: WARNING - Property parentNode never defined on this of type DomRepeat{__isDetached:boolean} - let parent = this.parentNode; - ^^^^^^^^^^^^^^^ - /polymer.html_script_30.js:302: WARNING - Cannot add property template to a struct instance after it is constructed. let template = this.template = this.querySelector('template'); ^^^^^^^^^^^^^ -/polymer.html_script_30.js:302: WARNING - Property querySelector never defined on this of type DomRepeat - let template = this.template = this.querySelector('template'); - ^^^^^^^^^^^^^^^^^^ - -/polymer.html_script_30.js:306: WARNING - Property querySelector never defined on $jscomp$this of type DomRepeat - if (this.querySelector('template')) { - ^^^^^^^^^^^^^^^^^^ - -/polymer.html_script_30.js:313: WARNING - Invalid type for parameter 1 of function observer.observe. -Expected : Node|null -Found : DomRepeat - - observer.observe(this, {childList: true}); - ^^^^ - /polymer.html_script_30.js:318: WARNING - Property as never defined on this of type DomRepeat instanceProps[this.as] = true; ^^^^^^^ @@ -920,10 +889,6 @@ Found : function(this:DomRepeat):? this._setRenderedItemCount(this.__instances.length); ^^^^^^^^^^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:486: WARNING - Property dispatchEvent never defined on this of type DomRepeat{__instances:{length:?} (loose), __pool:{length:number} (loose)} - this.dispatchEvent(new CustomEvent('dom-change', { - ^^^^^^^^^^^^^^^^^^ - /polymer.html_script_30.js:520: WARNING - Property as never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object{}, __limit:number, items:?=} inst._setPendingProperty(this.as, item); ^^^^^^^ @@ -960,10 +925,6 @@ Found : function(this:DomRepeat):? inst._setPendingProperty(this.itemsIndexAs, itemIdx); ^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:578: WARNING - Property parentNode never defined on this of type DomRepeat{__instances:Object, __pool:{pop:LOOSE_TOP_FUNCTION} (loose)} - this.parentNode.insertBefore(inst.root, beforeNode); - ^^^^^^^^^^^^^^^ - /polymer.html_script_30.js:605: WARNING - Property as never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object} let itemPath = this.as + (itemSubPath ? '.' + itemSubPath : ''); ^^^^^^^ @@ -980,44 +941,14 @@ Found : function(this:DomRepeat):? return Polymer.Templatize.modelForElement(this.template, el); ^^^^^^^^^^^^^ -/polymer.html_script_30.js:669: WARNING - Invalid type for parameter 2 of function customElements.define. -Expected : function(new:HTMLElement):? -Found : DomRepeat<|function(new:DomRepeat):undefined|> - - customElements.define(DomRepeat.is, DomRepeat); - ^^^^^^^^^ - /polymer.html_script_31.js:142: WARNING - Property _lastIf never defined on this of type DomIf{__instance:?, if:?=, restamp:?=} if (this.if != this._lastIf) { ^^^^^^^^^^^^ -/polymer.html_script_31.js:143: WARNING - Property dispatchEvent never defined on this of type DomIf{__instance:?, if:?=, restamp:?=} - this.dispatchEvent(new CustomEvent('dom-change', { - ^^^^^^^^^^^^^^^^^^ - /polymer.html_script_31.js:147: WARNING - Cannot add property _lastIf to a struct instance after it is constructed. this._lastIf = this.if; ^^^^^^^^^^^^ -/polymer.html_script_31.js:152: WARNING - Property parentNode never defined on this of type DomIf - let parentNode = this.parentNode; - ^^^^^^^^^^^^^^^ - -/polymer.html_script_31.js:156: WARNING - Property querySelector never defined on this of type DomIf - let template = this.querySelector('template'); - ^^^^^^^^^^^^^^^^^^ - -/polymer.html_script_31.js:160: WARNING - Property querySelector never defined on $jscomp$this of type DomIf - if (this.querySelector('template')) { - ^^^^^^^^^^^^^^^^^^ - -/polymer.html_script_31.js:167: WARNING - Invalid type for parameter 1 of function observer.observe. -Expected : Node|null -Found : DomIf - - observer.observe(this, {childList: true}); - ^^^^ - /polymer.html_script_31.js:170: WARNING - Cannot add property __ctor to a struct instance after it is constructed. this.__ctor = Polymer.Templatize.templatize(template, this, { ^^^^^^^^^^^ @@ -1046,10 +977,6 @@ Found : DomIf this.__invalidProps[Polymer.Path.root(prop)] = true; ^^^^ -/polymer.html_script_31.js:198: WARNING - Property previousSibling never defined on this of type DomIf{__ctor:truthy=, __instance:{children:?} (loose)} - let lastChild = this.previousSibling; - ^^^^^^^^^^^^^^^^^^^^ - /polymer.html_script_31.js:214: WARNING - Property __dataHost never defined on this of type DomIf{__instance:{_setPendingProperty:LOOSE_TOP_FUNCTION} (loose)} this.__instance._setPendingProperty(prop, this.__dataHost[prop]); ^^^^^^^^^^^^^^^ @@ -1058,13 +985,6 @@ Found : DomIf let hidden = this.__hideTemplateChildren__ || !this.if; ^^^^^^^ -/polymer.html_script_31.js:245: WARNING - Invalid type for parameter 2 of function customElements.define. -Expected : function(new:HTMLElement):? -Found : DomIf<|function(new:DomIf):undefined|> - - customElements.define(DomIf.is, DomIf); - ^^^^^ - /polymer.html_script_32.js:143: WARNING - Property items never defined on this of type ArraySelectorMixin if (selected.has(this.items[idx])) { ^^^^^^^^^^ @@ -1157,13 +1077,6 @@ Found : DomIf<|function(new:DomIf):undefined|> this.selected = this.selectedItem = item; ^^^^^^^^^^^^^^^^^ -/polymer.html_script_32.js:391: WARNING - Invalid type for parameter 2 of function customElements.define. -Expected : function(new:HTMLElement):? -Found : ArraySelector<|function(new:ArraySelector,...?):undefined|> - - customElements.define(ArraySelector.is, ArraySelector); - ^^^^^^^^^^^^^ - /polymer.html_script_33.js:47: WARNING - Returned type does not match declared return type. Expected : HTMLStyleElement|null Found : undefined @@ -1346,4 +1259,4 @@ externs/closure-types.js:762: WARNING - property toggle on interface Polymer_Arr Polymer_ArraySelectorMixin.prototype.toggle; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -0 error(s), 293 warning(s), 72.8% typed +0 error(s), 275 warning(s), 74.5% typed diff --git a/polymer-element.html b/polymer-element.html index 1dac595c13..bf0d07efee 100644 --- a/polymer-element.html +++ b/polymer-element.html @@ -28,6 +28,11 @@ * attribute deserialization, and property change observation */ const Element = Polymer.ElementMixin(HTMLElement); + /** + * @constructor + * @implements {Polymer_ElementMixin} + * @extends {HTMLElement} + */ Polymer.Element = Element; })(); \ No newline at end of file