next-redux-wrapper v7/v8 type errors with getInitialAppProps
smo043 opened this issue · 4 comments
Describe the bug
We upgraded next.js from v10 - v12.3.1 and we saw the typecasting was breaking we solved it with module augmentation for next-redux-wrapper v6.
declare module 'next/dist/shared/lib/utils' {
export interface NextPageContext<S = TemplateState, A extends Action = AnyAction> {
/**
* Provided by next-redux-wrapper: The redux store
*/
store: Store<S, A>;
}
}
store:
export const wrapper = createWrapper<Store<TemplateState>>(makeStore);
However, as we updated the next-redux-wrapper to v7(latest)/v8(latest), we started seeing typecasting errors, when we use getInitialAppProps.
Steps to reproduce the behavior:
- Use next js 12.3.1
- use next-redux-wrapper v7 latest or v8 latest
- redux: 4.1.1, react-redux: 7.2.5, redux-saga: 1.1.3
- add getInitialAppProps
- See the type error
Expected behavior
type errors should be resolved. Any help would be appreciated. Thanks.
Any help pls
I got this to work by inferring the type
type GetInitialProps = ReturnType<typeof wrapper.getInitialAppProps>
...
public static getInitialProps: GetInitialProps = wrapper.getInitialAppProps(
Not sure if this is correct though.
Also, my test itself is not working because of #494 so not sure if this "fix" does anything
@GGAlanSmithee - Thank you, I will give a try
@GGAlanSmithee - It didn't help. It would be helpful if the core team address this issue and release a version.