Imagine I am designing the following slice:
import { createSlice } from '@reduxjs/toolkit';
interface ThoughtListDisplayOptions {
shouldShowCreateDate: boolean
}
interface DisplayOptions {
thoughtsList: ThoughtListDisplayOptions
}
interface OptionsState {
display: DisplayOptions
}
const initialState:OptionsState = {
display: {
thoughtsList: {
shouldShowCreateDate: true
}
}
};
const optionsSlice = createSlice({
name: 'options',
initialState: initialState,
reducers: {
setThoughtListDisplayOptions: (state, action) => {
state.display.thoughtsList = action.payload;
}
}
});
interface State {
options: OptionsState
}
export const selectThoughtListDisplayOptions = (state: State) => state.options.display.thoughtsList;
If I want my selector to have typing support for autocomplete and other features, what is the proper way to type the State? Should there be a central State interface, or is defining an interface specific to the slice sufficient?