From 5a98aa545b3740c9a6afdaf11362b10f047367dc Mon Sep 17 00:00:00 2001 From: PaulMaly Date: Tue, 11 Sep 2018 18:23:07 +0300 Subject: [PATCH] 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. --- src/shared/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/shared/index.js b/src/shared/index.js index 066942f1a6..4bba44b0ea 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -140,6 +140,14 @@ export function setDev(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); }