esamattis / esamattis/immer-reducer
Cannot figure out how to declare
- Dominant language
- TypeScript
- Stars
- 223
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
I don't know whether to post this here or in TypeScript, and it's a request for help (not an issue at all) - but this seems to be an awfully wonky question that only makes sense with your fairly complex typesafety stuff. So here goes..
In short - I have a
class FXRateReducer implements ImmerReducer extends IActions {... }
IActions defines the functions on this class. Because this class includes saga's, and I need to be able to call from one saga to the next by using put. Because of this I want to access the actionCreators on this class.
actions: ActionCreators; // <-- member of FXRateReducer
The above fails to compile because IActions are not derived from ImmerReducerClass. However, if I change that definition to include it:
interface IActions extends ImmerReducerClass
I get the following
TS2420: Class 'FxRateReducer' incorrectly implements interface 'IActions'.
Type 'FxRateReducer' provides no match for the signature 'new (...args: any[]): ImmerReducer'.
Which is very strange, because FXRateReducer was previously passed into createActionCreators, which means it should be a valid template argument. I also can't seem to add this function in, it just seems to be ignored.
I can't seem to get past this point. I would love to have access to type-safe actions from within the FXRateReducer, but seem to be stuck here.
The end goal is to have a parent template class which provides access to actions to all sub-children, and also allows overriding of customName as I need multiple instances of the same reducer type.
Understandable if you don't have time/desire to help; your work is awesome and I appreciate it.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.