Skip to content

Commit

Permalink
slighly better typing for mixin funcion
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Apr 27, 2017
1 parent 346e2d5 commit b3dfd38
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 50 deletions.
77 changes: 31 additions & 46 deletions closure.log
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ Found : undefined
return window.Polymer._polymerFn(info);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_1.js:44: WARNING - Invalid type for parameter 1 of function cachingMixin.
Expected : Function|null
Found : T

let cachedMixin = cachingMixin(mixin);
^^^^^

/polymer.html_script_1.js:47: WARNING - Returned type does not match declared return type.
Expected : T
Found : function({__mixinSet:?} (loose)):{__mixinSet:?} (loose)

return function(base) {
^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_1.js:49: WARNING - Cannot access property __dedupeId of non-object type T.
if (baseSet && baseSet[mixin.__dedupeId]) {
^^^^^

/polymer.html_script_1.js:52: WARNING - Cannot call non-function type T
let extended = mixin(base);
^^^^^^^^^^^

/polymer.html_script_1.js:58: WARNING - Cannot access property __dedupeId of non-object type T.
extended.__mixinSet[mixin.__dedupeId] = true;
^^^^^

/polymer.html_script_10.js:144: WARNING - Property name never defined on trigger of type Object
let triggerPath = trigger.name;
^^^^^^^^^^^^
Expand Down Expand Up @@ -197,11 +223,6 @@ The found type is a union that includes an unexpected type: null
inst.__data[splicesPath] = {indexSplices: null};
^^^^^^^^^^^

/polymer.html_script_10.js:1042: WARNING - propertyEffectsBase extends non-object type ?.

const propertyEffectsBase = Polymer.TemplateStamp(Polymer.PropertyAccessors(superClass));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_10.js:1076: WARNING - Invalid type for parameter 1 of function Object.create.
Expected : Object|null
Found : *
Expand Down Expand Up @@ -485,11 +506,6 @@ Found : PropertyEffects
value = inst.__data[path];
^^^^^^^^^^^

/polymer.html_script_11.js:105: WARNING - polymerElementBase extends non-object type ?.

const polymerElementBase = Polymer.PropertyEffects(base);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_11.js:126: WARNING - Property properties never defined on klass of type HTMLElement
klass.properties : {};
^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -717,11 +733,6 @@ Found : PolymerElement
* @param {Polymer.Debouncer?} debouncer Debouncer object.
^^^^^^^^^^^^^^^^^

/polymer.html_script_14.js:31: WARNING - GestureEventListeners extends non-object type ?.

class GestureEventListeners extends superClass {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_21.js:189: WARNING - Dangerous use of the global THIS object
return this.node[method].apply(this.node, arguments);
^^^^
Expand All @@ -746,11 +757,6 @@ Found : PolymerElement
!(window.customElements.polyfillWrapFlushCallback);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_22.js:30: WARNING - legacyElementBase extends non-object type ?.

const legacyElementBase = Polymer.GestureEventListeners(Polymer.ElementMixin(base));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_22.js:863: WARNING - Function this.splice: called with 3 argument(s). Function requires at least 4 argument(s) and at most 4.
return this.splice(arrayOrPath, index, 1);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -803,16 +809,6 @@ Found : HTMLElement<|function(new:HTMLElement):?|>
window.Polymer._polymerFn = function(info) {
^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_25.js:67: WARNING - MutableData extends non-object type ?.

class MutableData extends superClass {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_25.js:138: WARNING - OptionalMutableData extends non-object type ?.

class OptionalMutableData extends superClass {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_25.js:170: WARNING - Property mutableData never defined on this of type OptionalMutableData
return mutablePropertyChange(this, property, value, old, this.mutableData);
^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -1214,11 +1210,6 @@ Found : DomIf<|function(new:DomIf):undefined|>
customElements.define(DomIf.is, DomIf);
^^^^^

/polymer.html_script_32.js:86: WARNING - ArraySelectorMixin extends non-object type ?.

constructor() {
^^^^^^^^^^^^^^^

/polymer.html_script_32.js:143: WARNING - Property items never defined on this of type ArraySelectorMixin
if (selected.has(this.items[idx])) {
^^^^^^^^^^
Expand Down Expand Up @@ -1332,6 +1323,10 @@ Found : Element
return this._style;
^^^^^^^^^^^^^^^^^^^

/polymer.html_script_34.js:5: WARNING - Property _mutablePropertyChange never defined on Polymer.MutableData of type function(?):?
let mutablePropertyChange = Polymer.MutableData._mutablePropertyChange;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_34.js:132: WARNING - Dangerous use of the global THIS object
return mutablePropertyChange(this, property, value, old, this.mutableData);
^^^^
Expand Down Expand Up @@ -1380,11 +1375,6 @@ Found : Element
let parts = this.split(path);
^^^^

/polymer.html_script_8.js:103: WARNING - PropertyAccessors extends non-object type ?.

constructor() {
^^^^^^^^^^^^^^^

/polymer.html_script_8.js:117: WARNING - Function this._attributeToProperty: called with 2 argument(s). Function requires at least 3 argument(s) and at most 3.
this._attributeToProperty(name, value);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -1419,11 +1409,6 @@ Found : PropertyAccessors{__serializing:boolean}
_setPendingProperty(property, value) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_9.js:106: WARNING - TemplateStamp extends non-object type ?.

class TemplateStamp extends superClass {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/polymer.html_script_9.js:110: WARNING - Cannot add property $ to a struct instance after it is constructed.
this.$ = null;
^^^^^^
Expand Down Expand Up @@ -1510,4 +1495,4 @@ externs/closure-types.js:759: WARNING - property toggle on interface Polymer_Arr
Polymer_ArraySelectorMixin.prototype.toggle;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 error(s), 331 warning(s), 72.6% typed
0 error(s), 328 warning(s), 72.6% typed
9 changes: 5 additions & 4 deletions lib/utils/mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@
* applications.
*
* @memberof Polymer
* @param {Function} mixin ES6 class expression mixin to wrap
* @return {Function} Wrapped mixin that deduplicates and memoizes
* @template T
* @param {T} mixin ES6 class expression mixin to wrap
* @return {T} Wrapped mixin that deduplicates and memoizes
* mixin applications to base
*/
Polymer.dedupingMixin = function(mixin) {
mixin = cachingMixin(mixin);
let cachedMixin = cachingMixin(mixin);
// maintain a unique id for each mixin
mixin.__dedupeId = ++dedupeId;
cachedMixin.__dedupeId = ++dedupeId;
return function(base) {
let baseSet = base.__mixinSet;
if (baseSet && baseSet[mixin.__dedupeId]) {
Expand Down

0 comments on commit b3dfd38

Please sign in to comment.