Skip to content

Commit b2972f0

Browse files
authored
fix: Made selector return types generic (#1688)
fixes #1687
1 parent ce7c33f commit b2972f0

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

packages/code-studio/src/styleguide/grid-examples/DataBarExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
22
import { Grid, MockDataBarGridModel } from '@deephaven/grid';
3-
import { ColorMap } from 'packages/grid/src/DataBarGridModel';
3+
import type { ColorMap } from '@deephaven/grid';
44

55
function DataBarExample(): JSX.Element {
66
const columnData = [100, 50, 20, 10, -10, -20, -50, -30, 100, 0, 1];

packages/iris-grid/src/IrisGridTableModelTemplate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ import {
3939
assertNotNull,
4040
} from '@deephaven/utils';
4141
import { TableUtils, Formatter, FormatterUtils } from '@deephaven/jsapi-utils';
42-
import {
42+
import type {
4343
AxisOption,
4444
DataBarOptions,
4545
DirectionOption,
4646
Marker,
4747
ValuePlacementOption,
48-
} from 'packages/grid/src/DataBarGridModel';
48+
} from '@deephaven/grid';
4949
import IrisGridModel from './IrisGridModel';
5050
import AggregationOperation from './sidebar/aggregations/AggregationOperation';
5151
import IrisGridUtils from './IrisGridUtils';

packages/redux/src/selectors.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import type {
2-
CustomizableWorkspace,
3-
RootState,
4-
WorkspaceSettings,
5-
} from './store';
1+
import type { UndoPartial } from '@deephaven/utils';
2+
import type { RootState, WorkspaceSettings } from './store';
63

74
const EMPTY_OBJECT = Object.freeze({});
85

@@ -52,15 +49,15 @@ export const getDefaultWorkspaceSettings = <State extends RootState>(
5249
// Workspace
5350
export const getWorkspace = <State extends RootState>(
5451
store: State
55-
): CustomizableWorkspace => {
52+
): State['workspace'] => {
5653
const { workspace } = store;
5754
return workspace;
5855
};
5956

6057
// Settings
6158
export const getSettings = <State extends RootState>(
6259
store: State
63-
): WorkspaceSettings => {
60+
): UndoPartial<State['workspace']['data']['settings']> => {
6461
const customizedSettings = getWorkspace(store).data.settings;
6562

6663
const settings = { ...getDefaultWorkspaceSettings(store) };
@@ -72,7 +69,7 @@ export const getSettings = <State extends RootState>(
7269
settings[key] = customizedSettings[key];
7370
}
7471
}
75-
return settings;
72+
return settings as UndoPartial<State['workspace']['data']['settings']>;
7673
};
7774

7875
export const getDefaultSettings = <State extends RootState>(

packages/utils/src/TypeUtils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ export type OnlyOneProp<T> = {
2727
[P in keyof T]: { [ONEPROP in P]: T[ONEPROP] };
2828
}[keyof T];
2929

30+
/**
31+
* Remove `Partial` wrapper from a type. Note that this is slightly different
32+
* than `Required` because it will preserve optional properties on the original
33+
* target type.
34+
*/
35+
export type UndoPartial<T> = T extends Partial<infer U> ? U : never;
36+
3037
/**
3138
* Util type to extract the value from an object.
3239
*

0 commit comments

Comments
 (0)