Skip to content

Commit e6e45a6

Browse files
committed
Add some Partial<> annotations.
Without these, it thinks that all of the possible keys are present. Fixing this is needed if we want to avoid '@typescript-eslint/no-unnecessary-condition' complaining about our 'prop in obj' tests.
1 parent 03dd8ce commit e6e45a6

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/reducers/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ const lastVisibleThreadTabSlug: Reducer<TabSlug> = (
176176
}
177177
};
178178

179-
const trackThreadHeights: Reducer<{ [key: ThreadsKey]: CssPixels }> = (
179+
const trackThreadHeights: Reducer<Partial<Record<ThreadsKey, CssPixels>>> = (
180180
state = {},
181181
action
182182
) => {

src/selectors/app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ export const getPanelLayoutGeneration: Selector<number> = (state) =>
5858
getApp(state).panelLayoutGeneration;
5959
export const getLastVisibleThreadTabSlug: Selector<TabSlug> = (state) =>
6060
getApp(state).lastVisibleThreadTabSlug;
61-
export const getTrackThreadHeights: Selector<{
62-
[key: ThreadsKey]: CssPixels;
63-
}> = (state) => getApp(state).trackThreadHeights;
61+
export const getTrackThreadHeights: Selector<
62+
Partial<Record<ThreadsKey, CssPixels>>
63+
> = (state) => getApp(state).trackThreadHeights;
6464
export const getIsNewlyPublished: Selector<boolean> = (state) =>
6565
getApp(state).isNewlyPublished;
6666
export const getExperimental: Selector<ExperimentalFlags> = (state) =>

src/types/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export type AppState = {
180180
readonly sidebarOpenCategories: Map<string, Set<number>>;
181181
readonly panelLayoutGeneration: number;
182182
readonly lastVisibleThreadTabSlug: TabSlug;
183-
readonly trackThreadHeights: Record<ThreadsKey, CssPixels>;
183+
readonly trackThreadHeights: Partial<Record<ThreadsKey, CssPixels>>;
184184
readonly isNewlyPublished: boolean;
185185
readonly isDragAndDropDragging: boolean;
186186
readonly isDragAndDropOverlayRegistered: boolean;

src/types/transforms.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,6 @@ export type Transform = TransformDefinitions[keyof TransformDefinitions];
350350
export type TransformType = Transform['type'];
351351

352352
export type TransformStack = Transform[];
353-
export type TransformStacksPerThread = { [key: ThreadsKey]: TransformStack };
353+
export type TransformStacksPerThread = Partial<
354+
Record<ThreadsKey, TransformStack>
355+
>;

0 commit comments

Comments
 (0)