Account Options

  1. Sign in
    Screen reader users: click this link for accessible mode. Accessible mode has the same essential features but works better with your reader.

    Books

    1. My library
    2. Help
    3. Advanced Book Search

    Typescript Stephen Grider [exclusive] Info

    interface SubtractAction type: 'subtract'; payload: number;

    type CounterAction = AddAction | SubtractAction; typescript stephen grider

    Grider dances a little jig here (metaphorically). He shows you that inside a reducer, when you check action.type === 'add' , TypeScript automatically knows that action.payload is a number . Not any . Not number | undefined . A number. interface SubtractAction type: 'subtract'

    Stephen Grider does not promise you will become a TypeScript contributor to the compiler. He promises you will never again push a bug where undefined is not a function at 2 AM. type CounterAction = AddAction | SubtractAction