Prefer "Discriminated Union" to optional types.
dancrew32 opened this issue · comments
Dan Masquelier commented
https://github.com/dancrew32/yee/blob/master/src/app_store.tsx#L3-L6
type ActionType = {
type: string;
thing?: string;
};
Prefer the non-optional discriminated union.
type ActionType =
| {type: 'INC', count: number},
| {type: 'DEC', count: number},
| {type: 'ADD_THING', thing: number},
| {type: 'REMOVE_THING', thing: number};