Skip to content

Commit

Permalink
narrowsReducer: Check operation match is exhaustive statically, too.
Browse files Browse the repository at this point in the history
This would cause Flow to give an error if there were any way to reach
this case consistent with the stated types.

The line that throws an exception is still helpful too, because like
much of our data this action object comes largely from the server --
so there's no static guarantee that it actually *does* follow the
stated types.  (This is an area where we don't currently have much of
a "crunchy shell".)
  • Loading branch information
gnprice committed Sep 23, 2019
1 parent 6bc328b commit 4f8ceb0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/chat/narrowsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import union from 'lodash.union';

import type { NarrowsState, Action } from '../types';
import { ensureUnreachable } from '../types';
import {
DEAD_QUEUE,
LOGOUT,
Expand Down Expand Up @@ -75,6 +76,7 @@ const eventUpdateMessageFlags = (state, action) => {
[narrowStr]: state[narrowStr].filter(id => !messagesSet.has(id)),
});
} else {
ensureUnreachable(operation);
throw new Error(
`Unexpected operation ${operation} in an EVENT_UPDATE_MESSAGE_FLAGS action`,
);
Expand Down

0 comments on commit 4f8ceb0

Please sign in to comment.