I recently started using TypeScript and Visual Studio Code. I encountered the following issue:
*[ts] Property 'payload' does not exist on type 'Actions'.
This is my code:
action.ts file:
import { Action } from '@ngrx/store';
import { Item } from '../models/list';
export class AddBookAction implements Action {
type = ActionTypes.ADD_BOOK;
constructor(public payload: Item) { }
}
export type Actions = AddBookAction;
reducer.ts
import * as list from 'action';
export function reducer(state = initialState, action: list.Actions): State {
switch (action.type) {
case list.ActionTypes.LOAD: {
return Object.assign({}, state, {
loading: true
});
}
case list.ActionTypes.LOAD_SUCCESS: {
const books = action.payload // Error here
return {
loaded: true,
loading: false,
ids: books.map(book => book.id)
};
}
}
Any suggestions or advice would be greatly appreciated.