title: State vs ActionReducer<State> as NgRx reducer return type
body: <p>I was reviewing the code for the <a href="https://github.com/ngrx/platform/blob/aedf20ed49b1b9e8274f155734f6284cf96e6b4b/example-app/app/books/reducers/books.ts" rel="nofollow noreferrer">example application provided by NgRx</a>. I noticed that each reducer function in the example application has a return value that is typed by the <code>State</code> interface for that particular reducer. For example, the books reducer has the following code:</p>
  
  <pre><code>export interface State {
    ids: string[];
    entities: { [id: string]: Book };
    selectedBookId: string | null;
  }
  
  export const initialState: State = {
    ids: [],
    entities: {},
    selectedBookId: null,
  };
  
  export function reducer(
    state = initialState,
    action: book.Actions | collection.Actions
  ): State {
  </code></pre>
  
  <p>Later on, I was reading a book about NgRx titled <a href="https://books.google.com/books?id=fzckDwAAQBAJ&amp;lpg=PR2&amp;dq=ngrx&amp;pg=PR2#v=onepage&amp;q=ngrx&amp;f=false" rel="nofollow noreferrer">Reactive Programming with Angular and NgRx</a> by Oren Farhi, and came across a code snippet showing the common body structure of a reducer function (on pages 24-25.) The code for the common structure shows the return value of the reducer function as being typed by <code>ActionReducer</code> with <code>State</code> as the type parameter (called <code>SomeInterface</code> rather than <code>State</code> in this case):</p>
  
  <pre><code>export interface SomeInterface {
    items: Item[],
    filter: string
  }
  
  let initialState: SomeInterface = {
    items: [],
    filter: ''
  }
  
  export function MyReducer (
    state: SomeInterface = initialState,
    action: Action
  ): ActionReducer&lt;SomeInterface&gt; {
  </code></pre>
  
  <p>Why does one code sample use State and the other uses ActionReducer with State as the type parameter for the return value of reducer functions? Why would one choose one of these function signatures over the other? What purpose does each serve?</p>
  
  <p>The book is written for NgRx 2.2.1 whereas the example application is for the latest version of NgRx (version 4.1.1.) I’m guessing that the difference in return types cannot simply be explained by the difference in NgRx versions, as the latest version of NgRx has ActionReducer as well.</p>
  
  <p>Thank you!</p>