esamattis / immer-reducer

Type-safe and terse reducers with Typescript for React Hooks and Redux
http://npm.im/immer-reducer
MIT License
224 stars 15 forks source link

Export ActionCreators type to allow re-exporting generated actionCreators #42

Open FrozenKiwi opened 5 years ago

FrozenKiwi commented 5 years ago

I'm creating a library to allow shimming my redux store with test data, but while keeping the interfaces/actions generated by immer-reducer, combined with TS project references.

I use the compiler switch "declarations" so we generate .d.ts files, however with this switch we get compiler errors on our exported reducer functions

export const uploadReducer = createReducerFunction(UploadReducer, initialState);

Exported variable 'A' has or is using name 'ImmerReducerFunction' from external module ".../immer-reducer/lib/immer-reducer" but cannot be named.

From googling, it appears that because this type isn't exported from immer-reducer, TS seems to not be able to generate the .d.ts files describing it.

Current workaround is to set reducers to type "any", which isn't a big deal but sub-optimal

export const uploadReducer: any = createReducerFunction(UploadReducer, initialState);

hcharley commented 4 years ago

I ran into this as well.