You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a difference between the contents of /src/utils/combineReducers.js as published on github and what is pulled down from a fresh npm install.
importImmutablefrom'immutable';// TODO need to find a way to reference Redux's init for compatabilityconstActionTypes={INIT: 'INIT'};constisImmutable=(obj)=>{returnImmutable.Iterable.isIterable(obj);};/* eslint-disable no-console */functiongetErrorMessage(key,action){varactionType=action&&action.type;varactionName=actionType&&`"${actionType.toString()}"`||'an action';return(`Reducer "${key}" returned undefined handling ${actionName}. `+`To ignore an action, you must explicitly return the previous state.`);}functionverifyStateShape(initialState,currentState){varreducerKeys=currentState.keySeq();if(reducerKeys.size===0){console.error('Store does not have a valid reducer. Make sure the argument passed '+'to combineReducers is an object whose values are reducers.');return;}if(!isImmutable(initialState)){console.error('initialState has unexpected type of "'+({}).toString.call(initialState).match(/\s([a-z|A-Z]+)/)[1]+'". Expected initialState to be an instance of Immutable.Iterable with the following '+`keys: "${reducerKeys.join('", "')}"`);return;}constunexpectedKeys=initialState.keySeq().filter(key=>reducerKeys.indexOf(key)<0);if(unexpectedKeys.size>0){console.error(`Unexpected ${unexpectedKeys.length>1 ? 'keys' : 'key'} `+`"${unexpectedKeys.join('", "')}" in initialState will be ignored. `+`Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}"`);}}/** * Turns an object whose values are different reducer functions, into a single * reducer function. It will call every child reducer, and gather their results * into a single state object, whose keys correspond to the keys of the passed * reducer functions. * * @param {Object} reducers An object whose values correspond to different * reducer functions that need to be combined into one. One handy way to obtain * it is to use ES6 `import * as reducers` syntax. The reducers may never return * undefined for any action. Instead, they should return their initial state * if the state passed to them was undefined, and the current state for any * unrecognized action. * * @returns {Function} A reducer function that invokes every reducer inside the * passed object, and builds a state object with the same shape. */exportdefaultfunctioncombineReducers(reducers){reducers=isImmutable(reducers) ? reducers : Immutable.fromJS(reducers);constfinalReducers=reducers.filter(v=>typeofv==='function');finalReducers.forEach((reducer,key)=>{if(typeofreducer(undefined,{type: ActionTypes.INIT})==='undefined'){thrownewError(`Reducer "${key}" returned undefined during initialization. `+`If the state passed to the reducer is undefined, you must `+`explicitly return the initial state. The initial state may `+`not be undefined.`);}vartype=Math.random().toString(36).substring(7).split('').join('.');if(typeofreducer(undefined,{ type })==='undefined'){thrownewError(`Reducer "${key}" returned undefined when probed with a random type. `+`Don't try to handle ${ActionTypes.INIT} or other actions in "redux/*" `+`namespace. They are considered private. Instead, you must return the `+`current state for any unknown actions, unless it is undefined, `+`in which case you must return the initial state, regardless of the `+`action type. The initial state may not be undefined.`);}});vardefaultState=finalReducers.map(r=>undefined);varstateShapeVerified;returnfunctioncombination(state=defaultState,action){vardirty=false;varfinalState=finalReducers.map((reducer,key)=>{varoldState=state.get(key);varnewState=reducer(oldState,action);dirty=dirty||(oldState!==newState)if(typeofnewState==='undefined'){thrownewError(getErrorMessage(key,action));}returnnewState;});if((// Node-like CommonJS environments (Browserify, Webpack)typeofprocess!=='undefined'&&typeofprocess.env!=='undefined'&&process.env.NODE_ENV!=='production')||// React Nativetypeof__DEV__!=='undefined'&&__DEV__// eslint-disable-line no-undef){if(!stateShapeVerified){verifyStateShape(state,finalState);stateShapeVerified=true;}}return(dirty) ? finalState : state;};}
Which is pretty different from what i'm getting locally from npm
importImmutablefrom'immutable';// TODO need to find a way to reference Redux's init for compatabilityconstActionTypes={INIT: 'INIT'};constisImmutable=(obj)=>{returnImmutable.Iterable.isIterable(obj);};/* eslint-disable no-console */functiongetUndefinedStateErrorMessage(key,action){varactionType=action&&action.type;varactionName=actionType&&`"${actionType.toString()}"`||'an action';return(`Reducer "${key}" returned undefined handling ${actionName}. `+`To ignore an action, you must explicitly return the previous state.`);}functiongetUnexpectedStateKeyWarningMessage(inputState,outputState,action){varreducerKeys=Object.keys(outputState);varargumentName=action&&action.type===ActionTypes.INIT ?
'initialState argument passed to createStore' :
'previous state received by the reducer';if(reducerKeys.length===0){return('Store does not have a valid reducer. Make sure the argument passed '+'to combineReducers is an object whose values are reducers.');}if(!isImmutable(inputState)){return(`The ${argumentName} has unexpected type of "`+({}).toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1]+`". Expected argument to be an object with the following `+`keys: "${reducerKeys.join('", "')}"`);}varunexpectedKeys=inputState.keySeq().filter(key=>reducerKeys.indexOf(key)<0);if(unexpectedKeys.size>0){return(`Unexpected ${unexpectedKeys.length>1 ? 'keys' : 'key'} `+`"${unexpectedKeys.join('", "')}" found in ${argumentName}. `+`Expected to find one of the known reducer keys instead: `+`"${reducerKeys.join('", "')}". Unexpected keys will be ignored.`);}}functionassertReducerSanity(reducers){reducers.keySeq().forEach(key=>{varreducer=reducers.get(key);varinitialState=reducer(undefined,{type: ActionTypes.INIT});if(typeofinitialState==='undefined'){thrownewError(`Reducer "${key}" returned undefined during initialization. `+`If the state passed to the reducer is undefined, you must `+`explicitly return the initial state. The initial state may `+`not be undefined.`);}vartype='@@redux/PROBE_UNKNOWN_ACTION_'+Math.random().toString(36).substring(7).split('').join('.');if(typeofreducer(undefined,{ type })==='undefined'){thrownewError(`Reducer "${key}" returned undefined when probed with a random type. `+`Don't try to handle ${ActionTypes.INIT} or other actions in "redux/*" `+`namespace. They are considered private. Instead, you must return the `+`current state for any unknown actions, unless it is undefined, `+`in which case you must return the initial state, regardless of the `+`action type. The initial state may not be undefined.`);}});}/** * Turns an object whose values are different reducer functions, into a single * reducer function. It will call every child reducer, and gather their results * into a single state object, whose keys correspond to the keys of the passed * reducer functions. * * @param {Object} reducers An object whose values correspond to different * reducer functions that need to be combined into one. One handy way to obtain * it is to use ES6 `import * as reducers` syntax. The reducers may never return * undefined for any action. Instead, they should return their initial state * if the state passed to them was undefined, and the current state for any * unrecognized action. * * @returns {Function} A reducer function that invokes every reducer inside the * passed object, and builds a state object with the same shape. */exportdefaultfunctioncombineReducers(reducers){letfinalReducers=isImmutable(reducers) ? reducers : Immutable.fromJS(reducers);finalReducers=finalReducers.filter(v=>typeofv==='function');varsanityError;try{assertReducerSanity(finalReducers);}catch(e){sanityError=e;}vardefaultState=finalReducers.map(r=>undefined);returnfunctioncombination(state=defaultState,action){if(sanityError){throwsanityError;}vardirty=false;varfinalState=finalReducers.map((reducer,key)=>{varoldState=state.get(key);varnewState=reducer(oldState,action);dirty=dirty||(oldState!==newState)if(typeofnewState==='undefined'){thrownewError(getErrorMessage(key,action));}returnnewState;});if(process.env.NODE_ENV!=='production'){varwarningMessage=getUnexpectedStateKeyWarningMessage(state,finalState,action);if(warningMessage){console.error(warningMessage);}}return(dirty) ? finalState : state;};}
I'm wondering why if there was an update to the code that was not pushed to github as well? Also makes me wonder what other files are different or if this is an isolated case
The text was updated successfully, but these errors were encountered:
@indexiatech those differences may actually break this repo (for example getErrorMessage may be called although they do not exist in the published code, so it throws errors)
This does break things, as getErrorMessage is not defined in the published 0.0.8, and instead we get that error about it not being defined. This is still an issue two years later.
There seems to be a difference between the contents of /src/utils/combineReducers.js as published on github and what is pulled down from a fresh npm install.
The differences start almost immediately, here's the current github version of the file from https://github.com/indexiatech/redux-immutablejs/blob/master/src/utils/combineReducers.js
Which is pretty different from what i'm getting locally from npm
I'm wondering why if there was an update to the code that was not pushed to github as well? Also makes me wonder what other files are different or if this is an isolated case
The text was updated successfully, but these errors were encountered: