dancrew32 / yee

parcel -> hookrouter, suspense, createContext, useReducer, useContext pattern

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prefer "Discriminated Union" to optional types.

dancrew32 opened this issue · comments

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};