Skip to content

Commit fe81676

Browse files
authored
Merge pull request #5550 from Polymer/externs-fixes-1
Various compilation fixes for externs
2 parents 05231a0 + f0fb532 commit fe81676

16 files changed

+93
-63
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ sudo: false
33
dist: trusty
44
node_js: '9'
55
addons:
6-
firefox: latest
6+
firefox: "66.0"
77
chrome: stable
88
cache:
99
directories:

lib/elements/custom-style.js

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class CustomStyle extends HTMLElement {
8787
const include = style.getAttribute(attr);
8888
if (include) {
8989
style.removeAttribute(attr);
90+
/** @suppress {deprecated} */
9091
style.textContent = cssFromModules(include) + style.textContent;
9192
}
9293
/*

lib/elements/dom-bind.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,16 @@ export class DomBind extends domBindBase {
6262
this.__children = null;
6363
}
6464

65+
/* eslint-disable no-unused-vars */
6566
/**
6667
* @override
68+
* @param {string} name Name of attribute that changed
69+
* @param {?string} old Old attribute value
70+
* @param {?string} value New attribute value
71+
* @param {?string} namespace Attribute namespace.
6772
* @return {void}
6873
*/
69-
attributeChangedCallback() {
74+
attributeChangedCallback(name, old, value, namespace) {
7075
// assumes only one observed attribute
7176
this.mutableData = true;
7277
}

lib/elements/dom-repeat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export class DomRepeat extends domRepeatBase {
297297
this.__sortFn = null;
298298
this.__filterFn = null;
299299
this.__observePaths = null;
300-
/** @type {?function(new:Polymer.TemplateInstanceBase, *)} */
300+
/** @type {?function(new:TemplateInstanceBase, *)} */
301301
this.__ctor = null;
302302
this.__isDetached = true;
303303
this.template = null;

lib/mixins/dir-mixin.js

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ function takeRecords() {
8383
* @mixinFunction
8484
* @polymer
8585
* @appliesMixin PropertyAccessors
86+
* @template T
87+
* @param {function(new:T)} superClass Class to apply mixin to.
88+
* @return {function(new:T)} superClass with mixin applied.
8689
*/
8790
export const DirMixin = dedupingMixin((base) => {
8891

lib/mixins/disable-upgrade-mixin.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const DISABLED_ATTR = 'disable-upgrade';
3838
* @mixinFunction
3939
* @polymer
4040
* @appliesMixin ElementMixin
41+
* @template T
42+
* @param {function(new:T)} superClass Class to apply mixin to.
43+
* @return {function(new:T)} superClass with mixin applied.
4144
*/
4245
export const DisableUpgradeMixin = dedupingMixin((base) => {
4346
/**
@@ -67,8 +70,8 @@ export const DisableUpgradeMixin = dedupingMixin((base) => {
6770
* @param {string} name Attribute name.
6871
* @param {?string} old The previous value for the attribute.
6972
* @param {?string} value The new value for the attribute.
70-
* @param {?string=} namespace The XML namespace for the attribute.
71-
* @return {undefined}
73+
* @param {?string} namespace The XML namespace for the attribute.
74+
* @return {void}
7275
*/
7376
attributeChangedCallback(name, old, value, namespace) {
7477
if (name == DISABLED_ATTR) {

lib/mixins/element-mixin.js

+3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ const builtCSS = window.ShadyCSS && window.ShadyCSS['cssBuild'];
9595
* import strategies.
9696
* @summary Element class mixin that provides the core API for Polymer's
9797
* meta-programming features.
98+
* @template T
99+
* @param {function(new:T)} superClass Class to apply mixin to.
100+
* @return {function(new:T)} superClass with mixin applied.
98101
*/
99102
export const ElementMixin = dedupingMixin(base => {
100103
/**

lib/mixins/gesture-event-listeners.js

+39-54
Original file line numberDiff line numberDiff line change
@@ -24,63 +24,48 @@ import { addListener, removeListener } from '../utils/gestures.js';
2424
* @mixinFunction
2525
* @polymer
2626
* @summary Element class mixin that provides API for adding Polymer's
27-
* cross-platform
28-
* gesture events to nodes
27+
* cross-platform gesture events to nodes
28+
* @template T
29+
* @param {function(new:T)} superClass Class to apply mixin to.
30+
* @return {function(new:T)} superClass with mixin applied.
2931
*/
30-
const _GestureEventListeners = dedupingMixin(
32+
export const GestureEventListeners = dedupingMixin((superClass) => {
33+
/**
34+
* @polymer
35+
* @mixinClass
36+
* @implements {Polymer_GestureEventListeners}
37+
*/
38+
class GestureEventListeners extends superClass {
3139
/**
32-
* @template T
33-
* @param {function(new:T)} superClass Class to apply mixin to.
34-
* @return {function(new:T)} superClass with mixin applied.
40+
* Add the event listener to the node if it is a gestures event.
41+
*
42+
* @param {!EventTarget} node Node to add event listener to
43+
* @param {string} eventName Name of event
44+
* @param {function(!Event):void} handler Listener function to add
45+
* @return {void}
46+
* @override
3547
*/
36-
(superClass) => {
37-
/**
38-
* @polymer
39-
* @mixinClass
40-
* @implements {Polymer_GestureEventListeners}
41-
*/
42-
class GestureEventListeners extends superClass {
43-
/**
44-
* Add the event listener to the node if it is a gestures event.
45-
*
46-
* @param {!EventTarget} node Node to add event listener to
47-
* @param {string} eventName Name of event
48-
* @param {function(!Event):void} handler Listener function to add
49-
* @return {void}
50-
* @override
51-
*/
52-
_addEventListenerToNode(node, eventName, handler) {
53-
if (!addListener(node, eventName, handler)) {
54-
super._addEventListenerToNode(node, eventName, handler);
55-
}
56-
}
57-
58-
/**
59-
* Remove the event listener to the node if it is a gestures event.
60-
*
61-
* @param {!EventTarget} node Node to remove event listener from
62-
* @param {string} eventName Name of event
63-
* @param {function(!Event):void} handler Listener function to remove
64-
* @return {void}
65-
* @override
66-
*/
67-
_removeEventListenerFromNode(node, eventName, handler) {
68-
if (!removeListener(node, eventName, handler)) {
69-
super._removeEventListenerFromNode(node, eventName, handler);
70-
}
71-
}
48+
_addEventListenerToNode(node, eventName, handler) {
49+
if (!addListener(node, eventName, handler)) {
50+
super._addEventListenerToNode(node, eventName, handler);
7251
}
52+
}
7353

74-
return GestureEventListeners;
75-
});
54+
/**
55+
* Remove the event listener to the node if it is a gestures event.
56+
*
57+
* @param {!EventTarget} node Node to remove event listener from
58+
* @param {string} eventName Name of event
59+
* @param {function(!Event):void} handler Listener function to remove
60+
* @return {void}
61+
* @override
62+
*/
63+
_removeEventListenerFromNode(node, eventName, handler) {
64+
if (!removeListener(node, eventName, handler)) {
65+
super._removeEventListenerFromNode(node, eventName, handler);
66+
}
67+
}
68+
}
7669

77-
// Somehow _GestureEventListeners is incorrectly typed as *. For now add this
78-
// cast.
79-
/**
80-
* @template T
81-
* @param {function(new:T)} superClass Class to apply mixin to.
82-
* @return {function(new:T)} superClass with mixin applied.
83-
*/
84-
export const GestureEventListeners = function(superClass) {
85-
return _GestureEventListeners(superClass);
86-
};
70+
return GestureEventListeners;
71+
});

lib/mixins/mutable-data.js

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ function mutablePropertyChange(inst, property, value, old, mutableData) {
6767
* @polymer
6868
* @summary Element class mixin to skip strict dirty-checking for objects
6969
* and arrays
70+
* @template T
71+
* @param {function(new:T)} superClass Class to apply mixin to.
72+
* @return {function(new:T)} superClass with mixin applied.
7073
*/
7174
export const MutableData = dedupingMixin(superClass => {
7275

lib/mixins/properties-changed.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ const microtask = microTask;
3333
* @polymer
3434
* @summary Element class mixin for reacting to property changes from
3535
* generated property accessors.
36+
* @template T
37+
* @param {function(new:T)} superClass Class to apply mixin to.
38+
* @return {function(new:T)} superClass with mixin applied.
3639
*/
3740
export const PropertiesChanged = dedupingMixin(
3841
/**
@@ -161,7 +164,7 @@ export const PropertiesChanged = dedupingMixin(
161164

162165
constructor() {
163166
super();
164-
/** @protected {boolean} */
167+
/** @type {boolean} */
165168
this.__dataEnabled = false;
166169
this.__dataReady = false;
167170
this.__dataInvalid = false;
@@ -426,7 +429,7 @@ export const PropertiesChanged = dedupingMixin(
426429
* @param {string} name Name of attribute that changed
427430
* @param {?string} old Old attribute value
428431
* @param {?string} value New attribute value
429-
* @param {?string=} namespace Attribute namespace.
432+
* @param {?string} namespace Attribute namespace.
430433
* @return {void}
431434
* @suppress {missingProperties} Super may or may not implement the callback
432435
* @override

lib/mixins/properties-mixin.js

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ function normalizeProperties(props) {
4747
* @appliesMixin PropertiesChanged
4848
* @summary Mixin that provides a minimal starting point for using
4949
* the PropertiesChanged mixin by providing a declarative `properties` object.
50+
* @template T
51+
* @param {function(new:T)} superClass Class to apply mixin to.
52+
* @return {function(new:T)} superClass with mixin applied.
5053
*/
5154
export const PropertiesMixin = dedupingMixin(superClass => {
5255

lib/mixins/property-accessors.js

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ function saveAccessorValue(model, property) {
9191
* @appliesMixin PropertiesChanged
9292
* @summary Element class mixin for reacting to property changes from
9393
* generated property accessors.
94+
* @template T
95+
* @param {function(new:T)} superClass Class to apply mixin to.
96+
* @return {function(new:T)} superClass with mixin applied.
9497
*/
9598
export const PropertyAccessors = dedupingMixin(superClass => {
9699

lib/mixins/property-effects.js

+6
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,9 @@ function upper(name) {
10791079
* @appliesMixin PropertyAccessors
10801080
* @summary Element class mixin that provides meta-programming for Polymer's
10811081
* template binding and data observation system.
1082+
* @template T
1083+
* @param {function(new:T)} superClass Class to apply mixin to.
1084+
* @return {function(new:T)} superClass with mixin applied.
10821085
*/
10831086
export const PropertyEffects = dedupingMixin(superClass => {
10841087

@@ -1150,6 +1153,9 @@ export const PropertyEffects = dedupingMixin(superClass => {
11501153
this.__templateInfo;
11511154
}
11521155

1156+
/**
1157+
* @return {!Object<string, string>} Effect prototype property name map.
1158+
*/
11531159
get PROPERTY_EFFECT_TYPES() {
11541160
return TYPES;
11551161
}

lib/mixins/strict-binding-parser.js

+3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ function storeMethodNumber(bindingData, text, i) {
115115
* @appliesMixin PropertyEffects
116116
* @polymer
117117
* @summary Mixin that parses binding expressions and generates corresponding metadata.
118+
* @template T
119+
* @param {function(new:T)} superClass Class to apply mixin to.
120+
* @return {function(new:T)} superClass with mixin applied.
118121
*/
119122
const StrictBindingParser = dedupingMixin((base) => {
120123

lib/mixins/template-stamp.js

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ function createNodeEventHandler(context, eventName, methodName) {
104104
* @mixinFunction
105105
* @polymer
106106
* @summary Element class mixin that provides basic template parsing and stamping
107+
* @template T
108+
* @param {function(new:T)} superClass Class to apply mixin to.
109+
* @return {function(new:T)} superClass with mixin applied.
107110
*/
108111
export const TemplateStamp = dedupingMixin(
109112
/**

lib/utils/templatize.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ function upgradeTemplate(template, constructor) {
101101
* @implements {Polymer_PropertyEffects}
102102
* @private
103103
*/
104-
const templateInstanceBase = PropertyEffects(class {});
104+
const templateInstanceBase = PropertyEffects(
105+
// This cast shouldn't be neccessary, but Closure doesn't understand that
106+
// "class {}" is a constructor function.
107+
/** @type {function(new:Object)} */(class {}));
105108

106109
/**
107110
* @polymer
@@ -317,7 +320,10 @@ TemplateInstanceBase.prototype.__hostProps;
317320
* @implements {Polymer_MutableData}
318321
* @private
319322
*/
320-
const MutableTemplateInstanceBase = MutableData(TemplateInstanceBase);
323+
const MutableTemplateInstanceBase = MutableData(
324+
// This cast shouldn't be necessary, but Closure doesn't seem to understand
325+
// this constructor.
326+
/** @type {function(new:TemplateInstanceBase)} */(TemplateInstanceBase));
321327

322328
function findMethodHost(template) {
323329
// Technically this should be the owner of the outermost template.

0 commit comments

Comments
 (0)