Simple type-checking in dev-mode

Displays the warning in console if the type of the new value of data property isn't equal to previous. Important in development when interfaces of components are still too fluid.
pull/1724/head^2
PaulMaly 7 years ago committed by GitHub
parent a4d412fb53
commit 7acb98eca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -138,8 +138,16 @@ export function setDev(newState) {
this._debugName + '.set was called without an object of data key-values to update.' this._debugName + '.set was called without an object of data key-values to update.'
); );
} }
this._checkReadOnly(newState); this._checkReadOnly(newState);
Object.keys(newState).forEach(prop => {
if (prop in this._state && typeof this._state[prop] !== 'undefined'
&& typeof this._state[prop] !== typeof newState[prop]) {
console.warn('Type of data property "' + prop + '" not match with previous one.');
}
});
set.call(this, newState); set.call(this, newState);
} }

Loading…
Cancel
Save