I am new to TypeScript and Visual Studio Code. I get the following error:
*[ts] Property 'payload' does not exist on type 'Actions'.
My code is:
file action.ts:
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
return {
loaded: true,
loading: false,
ids: books.map(book => book.id)
};
}
}
Any advice would be very helpful.
source
share