Skip to content

Commit

Permalink
Add type for state.controls.defaults
Browse files Browse the repository at this point in the history
Partial<ControlsState> previously worked but has the side effect of
marking all keys as optional, which is not accurate and prone to cause
future type errors.
  • Loading branch information
victorlin committed Oct 11, 2024
1 parent 4d8a2e0 commit b1a26c6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/reducers/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ import { calcBrowserDimensionsInitialState } from "./browserDimensions";
import { doesColorByHaveConfidence } from "../actions/recomputeReduxState";
import { hasMultipleGridPanels } from "../actions/panelDisplay";

interface Defaults {
distanceMeasure: string
layout: string
geoResolution: string
filters: Record<string, any>
filtersInFooter: string[]
colorBy: string
selectedBranchLabel: string
tipLabelKey: typeof strainSymbol
showTransmissionLines: boolean
sidebarOpen?: boolean
}

export interface BasicControlsState {
defaults: Defaults
panelsAvailable: string[]
panelsToDisplay: string[]
showTreeToo: boolean
Expand Down Expand Up @@ -40,7 +54,7 @@ export interface ControlsState extends BasicControlsState, MeasurementsControlSt
at any time, e.g. if we want to revert things (e.g. on dataset change)
*/
export const getDefaultControlsState = () => {
const defaults: Partial<ControlsState> = {
const defaults: Defaults = {
distanceMeasure: defaultDistanceMeasure,
layout: defaultLayout,
geoResolution: defaultGeoResolution,
Expand Down

0 comments on commit b1a26c6

Please sign in to comment.