Reputation: 11672
I have a todos
variable declare here:
const initialState = {
todos: []
};
export const todo = (state: RootState = initialState, action: Action) => {
switch (action.type) {
case TODO_ADD:
return {
todos: [...state.todos, action.payload.todo]
};
case TODO_TOGGLE_COMPLETE:
const todos = [...state.todos];
todos.forEach((todo: ToDo, index: number) => {
if (todo.id === action.payload.id) {
todos[index].isComplete = !todos[index].isComplete;
}
});
return {
todos
};
default:
return state;
}
};
But don't know why it always say not defined
Upvotes: 1
Views: 202
Reputation: 1074168
Unfortunately, this can happen sometimes with compiled/transpiled code (in your case, code compiled by tsc
). Source maps are good, but they're not perfect.
When you run into this, you may have to fall back to debugging the underlying generated JavaScript rather than using the source maps to make it seem like you're debugging your TypeScript code.
Upvotes: 1