Skip to content

Commit 2bd7a74

Browse files
matthewbbrandtMatthew Brandt
andauthored
refactor(*): Required used to construct sound types (#120)
Co-authored-by: Matthew Brandt <[email protected]>
1 parent c29b5a5 commit 2bd7a74

File tree

6 files changed

+13
-50
lines changed

6 files changed

+13
-50
lines changed

src/chakra-ui/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,15 @@ type Configuration = {
66
isVirtualized?: boolean;
77
};
88

9-
type ConfigurationSound = {
10-
isVirtualized: boolean;
11-
};
9+
type ConfigurationSound = Required<Configuration>;
1210

1311
type Options = {
1412
horizontalSpacing?: number;
1513
verticalSpacing?: number;
1614
striped?: boolean;
1715
};
1816

19-
type OptionsSound = {
20-
horizontalSpacing: number;
21-
verticalSpacing: number;
22-
striped: boolean;
23-
};
17+
type OptionsSound = Required<Options>;
2418

2519
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2620
const getCommonTheme = (options: OptionsSound, _: ConfigurationSound) => ({

src/mantine/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ type Configuration = {
66
isVirtualized?: boolean;
77
};
88

9-
type ConfigurationSound = {
10-
isVirtualized: boolean;
11-
};
9+
type ConfigurationSound = Required<Configuration>;
1210

1311
type Options = {
1412
horizontalSpacing?: number;
@@ -17,12 +15,7 @@ type Options = {
1715
highlightOnHover?: boolean;
1816
};
1917

20-
type OptionsSound = {
21-
horizontalSpacing: number;
22-
verticalSpacing: number;
23-
striped: boolean;
24-
highlightOnHover: boolean;
25-
};
18+
type OptionsSound = Required<Options>;
2619

2720
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2821
const getCommonTheme = (options: OptionsSound, _: ConfigurationSound) => ({

src/material-ui/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ type Configuration = {
66
isVirtualized?: boolean;
77
};
88

9-
type ConfigurationSound = {
10-
isVirtualized: boolean;
11-
};
9+
type ConfigurationSound = Required<Configuration>;
1210

1311
type Options = {
1412
horizontalSpacing?: number;
@@ -17,12 +15,7 @@ type Options = {
1715
highlightOnHover?: boolean;
1816
};
1917

20-
type OptionsSound = {
21-
horizontalSpacing: number;
22-
verticalSpacing: number;
23-
striped: boolean;
24-
highlightOnHover: boolean;
25-
};
18+
type OptionsSound = Required<Options>;
2619

2720
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2821
const getCommonTheme = (options: OptionsSound, _: ConfigurationSound) => ({

src/types/pagination.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ export type PaginationOptions = {
55
isServer?: boolean;
66
};
77

8-
export type PaginationOptionsSound = {
9-
isServer: boolean;
10-
};
8+
export type PaginationOptionsSound = Required<PaginationOptions>;
119

1210
export type PaginationFunctions = {
1311
onSetPage: (page: number) => void;

src/types/select.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ export type SelectOptions = {
2121
isPartialToAll?: boolean;
2222
};
2323

24-
export type SelectOptionsSound = {
25-
clickType: SelectClickTypes;
26-
rowSelect: SelectTypes;
27-
buttonSelect: SelectTypes;
28-
isCarryForward: boolean;
29-
isPartialToAll: boolean;
30-
};
24+
export type SelectOptionsSound = Required<SelectOptions>;
3125

3226
export type CellSelectProps<T extends TableNode> = {
3327
item: T;

src/types/sort.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,12 @@ export type SortOptions = {
3232
isRecursive?: boolean;
3333
};
3434

35-
export type SortOptionsIconSound = {
36-
position: SortIconPositions;
37-
margin: string;
38-
size: string;
39-
iconDefault: React.ReactElement | Nullish;
40-
iconUp: React.ReactElement | Nullish;
41-
iconDown: React.ReactElement | Nullish;
42-
};
35+
export type SortOptionsIconSound = Required<SortOptionsIcon>;
4336

44-
export type SortOptionsSound = {
45-
sortFns: Record<string, SortFn>;
46-
isServer: boolean;
47-
sortToggleType: SortToggleType;
48-
sortIcon: SortOptionsIconSound;
49-
isRecursive: boolean;
37+
type SortOptionsSound = {
38+
[K in keyof Required<SortOptions>]: K extends 'sortIcon'
39+
? SortOptionsIconSound
40+
: Required<SortOptions>[K];
5041
};
5142

5243
export type SortFunctionInput = {

0 commit comments

Comments
 (0)