Skip to content

Commit

Permalink
feat(core): add invariant for unknown reducer actions
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Dec 9, 2020
1 parent bea3731 commit 27d6281
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/autocomplete-core/src/stateReducer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { invariant } from '@algolia/autocomplete-shared';

import { getCompletion } from './getCompletion';
import { Reducer } from './types';
import { getItemsCount, getNextSelectedItemId } from './utils';
Expand Down Expand Up @@ -162,6 +164,11 @@ export const stateReducer: Reducer = (state, action) => {
}

default:
invariant(
false,
`The reducer action ${JSON.stringify(action.type)} is not supported.`
);

return state;
}
};

0 comments on commit 27d6281

Please sign in to comment.