You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We converted our project to using typesafe actions and it worked well until I touched the last reducer.
Having variables in the type names like: export const initSelectionFromState = createAction(SELECTION +' [DOC] INIT_FROM_STATE')()
can cause a type error TS2345 in the reducer to occur. It does not happen in all constellations, and it does not on the first handleAction call.
Removing the SELECTION variable from that name fixes it
Mandatory info
Are you extending internal types to enable type-free syntax with createReducer?
The text was updated successfully, but these errors were encountered:
haraldkrischner
changed the title
Getting TS2345 Error when I have got Variables in type names
Getting TS2345 Error when I have got variables in type names
Nov 22, 2019
Thanks for your quick response @piotrwitek
Yes, it looks like that is the case. Besides it took me quite a while to narrow it down, the workaround is quite easy. Though we intended to share the actions across entities in the first place.
Anyway, this project reduces a lot of IMHO awkward redux typescript boilerplate code and is a big win for our project, so thank you!
Description
We converted our project to using typesafe actions and it worked well until I touched the last reducer.
Having variables in the type names like:
export const initSelectionFromState = createAction(SELECTION +' [DOC] INIT_FROM_STATE')()
can cause a type error TS2345 in the reducer to occur. It does not happen in all constellations, and it does not on the first handleAction call.
Removing the SELECTION variable from that name fixes it
Mandatory info
createReducer
?How to Reproduce
CodeSandbox Link
https://codesandbox.io/s/typesafe-actions-reference-project-yl65h
see todos/actions.ts and todos/reducer.ts
The error in our project looks slighty different and breaks the whole app, while this seems still to work, but you see that it makes a difference.
Expected behavior
It should not cause an error, at least I want to understand why this happens… It took me a full day to track it down to this odd cause
Project Dependencies
The text was updated successfully, but these errors were encountered: