Closed haraldkrischner closed 4 years ago
Hey @haraldkrischner I think you're getting this: Limitations of TypeScript when working with string constants https://github.com/piotrwitek/typesafe-actions#constants
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!
Best H.
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 itMandatory info
createReducer
?declare module 'typesafe-actions' { export type Store = StateType<typeof import('../src/redux/store').default>;
}