Skip to content

Commit

Permalink
Fix most closure warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Dec 6, 2017
1 parent fa40f20 commit a12934c
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 262 deletions.
173 changes: 98 additions & 75 deletions externs/closure-types.js

Large diffs are not rendered by default.

161 changes: 0 additions & 161 deletions externs/polymer-closure-types.html

This file was deleted.

6 changes: 5 additions & 1 deletion externs/polymer-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* computed: (string | undefined),
* reflectToAttribute: (boolean | undefined),
* notify: (boolean | undefined),
* observer: (string | undefined)
* observer: (string | function(*,*) | undefined)
* }}
*/
let PolymerElementPropertiesMeta;
Expand Down Expand Up @@ -59,6 +59,10 @@ PolymerElementConstructor.observers;
/** @type {(!HTMLTemplateElement | string | undefined)} */
PolymerElementConstructor.template;

let PropertiesMixinConstructor = function (){};
/** @type {(!PolymerElementProperties | undefined)} */
PropertiesMixinConstructor.properties;

/**
* @param {!PolymerInit} init
* @return {!function(new:HTMLElement)}
Expand Down
2 changes: 1 addition & 1 deletion externs/polymer-internal-shared-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function StampedTemplate() { }
StampedTemplate.prototype.__noInsertionPoint;
/** @type {!Array<!Node>} */
StampedTemplate.prototype.nodeList;
/** @type {!Object<string, !Node>} */
/** @type {!Object<string, !Element>} */
StampedTemplate.prototype.$;
/** @type {!TemplateInfo | undefined} */
StampedTemplate.prototype.templateInfo;
Expand Down
20 changes: 12 additions & 8 deletions lib/legacy/legacy-element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,12 @@
* childNodes list is the same as the element's childNodes except that
* any `<content>` elements are replaced with the list of nodes distributed
* to the `<content>`, the result of its `getDistributedNodes` method.
* @this {Element}
* @return {Array<Node>} List of effective child nodes.
* @suppress {invalidCasts} LegacyElementMixin must be applied to an HTMLElement
*/
getEffectiveChildNodes() {
const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(this));
const thisEl = /** @type {Element} */ (this);
const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(thisEl));
return domApi.getEffectiveChildNodes();
}

Expand All @@ -496,11 +497,12 @@
* `selector`. These can be dom children or elements distributed to
* children that are insertion points.
* @param {string} selector Selector to run.
* @this {Element}
* @return {Array<Node>} List of distributed elements that match selector.
* @suppress {invalidCasts} LegacyElementMixin must be applied to an HTMLElement
*/
queryDistributedElements(selector) {
const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(this));
const thisEl = /** @type {Element} */ (this);
const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(thisEl));
return domApi.queryDistributedElements(selector);
}

Expand Down Expand Up @@ -601,12 +603,13 @@
* Checks whether an element is in this element's light DOM tree.
*
* @param {?Node} node The element to be checked.
* @this {Element}
* @return {boolean} true if node is in this element's light DOM tree.
* @suppress {invalidCasts} LegacyElementMixin must be applied to an HTMLElement
*/
isLightDescendant(node) {
return this !== node && this.contains(node) &&
this.getRootNode() === node.getRootNode();
const thisNode = /** @type {Node} */ (this);
return thisNode !== node && thisNode.contains(node) &&
thisNode.getRootNode() === node.getRootNode();
}

/**
Expand All @@ -628,9 +631,10 @@
* @param {string} property The css property name.
* @return {string} Returns the computed css property value for the given
* `property`.
* @suppress {invalidCasts} LegacyElementMixin must be applied to an HTMLElement
*/
getComputedStyleValue(property) {
return styleInterface.getComputedStyleValue(this, property);
return styleInterface.getComputedStyleValue(/** @type {!Element} */(this), property);
}

// debounce
Expand Down
27 changes: 22 additions & 5 deletions lib/mixins/element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
* @mixinFunction
* @polymer
* @appliesMixin Polymer.PropertyEffects
* @appliesMixin Polymer.PropertiesMixin
* @memberof Polymer
* @property rootPath {string} Set to the value of `Polymer.rootPath`,
* which defaults to the main document path
Expand All @@ -96,6 +97,7 @@
* @constructor
* @extends {base}
* @implements {Polymer_PropertyEffects}
* @implements {Polymer_PropertiesMixin}
*/
const polymerElementBase = Polymer.PropertiesMixin(Polymer.PropertyEffects(base));

Expand Down Expand Up @@ -191,7 +193,7 @@
* and/or provide an advanced api for manipulating them.
* Also consider adding warnings when an effect cannot be changed.
*
* @param {PolymerElement} proto Element class prototype to add accessors
* @param {!PolymerElement} proto Element class prototype to add accessors
* and effects to
* @param {string} name Name of the property.
* @param {Object} info Info object from which to create property effects.
Expand All @@ -211,7 +213,7 @@
// setup where multiple triggers for setting a property)
// While we do have `hasComputedEffect` this is set on the property's
// dependencies rather than itself.
if (info.computed && !proto._hasReadOnlyEffect(name)) {
if (info.computed && !proto._hasReadOnlyEffect(name)) {
proto._createComputedProperty(name, info.computed, allProps);
}
if (info.readOnly && !proto._hasReadOnlyEffect(name)) {
Expand Down Expand Up @@ -273,7 +275,15 @@
*/
class PolymerElement extends polymerElementBase {

static _finalizeClass() {
/**
* Override of PropertiesMixin _finalizeClass to create observers and
* find the template.
* @return {void}
* @protected
* @override
* @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do
*/
static _finalizeClass() {
super._finalizeClass();
if (this.hasOwnProperty(
JSCompiler_renameProperty('is', this)) && this.is) {
Expand All @@ -298,7 +308,14 @@

}

static createProperties(props) {
/**
* Override of PropertiesChanged createProperties to create accessors
* and property effects for all of the properties.
* @return {void}
* @protected
* @override
*/
static createProperties(props) {
for (let p in props) {
createPropertyFromConfig(this.prototype, p, props[p], props);
}
Expand Down Expand Up @@ -496,7 +513,7 @@
* flushes any pending properties, and updates shimmed CSS properties
* when using the ShadyCSS scoping/custom properties polyfill.
*
* @suppress {invalidCasts}
* @suppress {missingProperties, invalidCasts} Super may or may not implement the callback
*/
connectedCallback() {
if (window.ShadyCSS && this._template) {
Expand Down
Loading

0 comments on commit a12934c

Please sign in to comment.