Here is the interface I'm currently working with:
export interface withAuthState {
ready: boolean,
session: any
}
Additionally, I have developed the following Higher Order Component (HOC):
const withAuth = <P extends withAuthProps, S extends withAuthState>(
WrappedComponent: new (props: P) => RX.Component<P, S>
) => class WithAuth extends RX.Component<P & withAuthProps, S & withAuthState> {
constructor(props) {
super(props);
this.state = {
ready: false,
session: null
};
}
}
Unfortunately, I'm encountering an issue with setting the state in the constructor. The error message I receive is:
TS2322: Type '{ ready: false; session: null; }' is not assignable to type 'Readonly<S & withAuthState>'.
It seems like there is something crucial that I am missing, but I am unable to pinpoint what it is.
If anyone could provide some guidance on this matter, I would greatly appreciate it. Thank you in advance.