After setting up a redux module, I have organized the following files:
//state.tsx
export default interface State {
readonly user: any;
readonly isLoggedIn: boolean;
}
//types.tsx
export default {
REQUEST: 'authentication/REQUEST',
SUCCESS: 'authentication/SUCCESS',
FAILURE: 'authentication/FAILURE',
LOGOUT: 'authentication/LOGOUT'
};
//reducers.tsx
import Types from './types';
import State from './state';
import { Reducer, AnyAction } from 'redux';
const initialState: State = {
user: null,
isLoggedIn: false
};
export default class {
reducer: Reducer<State> = (
state: State = initialState,
action: AnyAction
) => {
// brahbrah
};
}
//index.tsx
import reducer from './reducers';
import Types from './types';
import State from './state';
export default {
reducer,
Types,
// How do I properly export the State definition in this default export?
};
However, I'm encountering an issue on how to export the definition of state interface in the index.tsx.
Simply putting State
in the export results in the error message
'State' only refers to a type, but is being used as a value here.
. I understand this is not the correct approach, so what is the proper way to export this definition?