Skip to content

Commit 2fef975

Browse files
committed
Fix typescript issues
1 parent db2cc1a commit 2fef975

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

polaris-react/src/components/OptionList/tests/OptionList.test.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,9 @@ function firstOption(
539539
options?: OptionDescriptor[],
540540
sections?: OptionListProps['sections'],
541541
): string {
542-
const firstOptionsValue =
543-
options == null || options === [] ? '' : options[0].value;
542+
const firstOptionsValue = options == null ? '' : options[0].value;
544543
const firstSectionOptionsValue =
545-
sections == null || sections === [] || sections[0].options === []
546-
? ''
547-
: sections[0].options[0].value;
544+
sections == null ? '' : sections[0].options[0].value;
548545
return firstOptionsValue || firstSectionOptionsValue;
549546
}
550547

polaris-react/src/components/ResourceList/ResourceList.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ const isBreakpointsXS = () => {
5757
parseFloat(toPx(tokens.breakpoints['breakpoints-sm']) ?? '');
5858
};
5959

60-
function defaultIdForItem<TItemType extends {id?: any}>(
61-
item: TItemType,
62-
index: number,
63-
) {
60+
function defaultIdForItem(item: any, index: number) {
6461
return Object.prototype.hasOwnProperty.call(item, 'id')
6562
? item.id
6663
: index.toString();

polaris-react/src/utilities/merge.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ export function merge<TSource1, TSource2, TSource3, TSource4, TSource5>(
2424
source5: TSource5,
2525
): TSource1 & TSource2 & TSource3 & TSource4 & TSource5;
2626
export function merge<TResult>(...objs: any[]): TResult;
27-
export function merge<TSource1, TSource2, TSource3, TSource4, TSource5>(
28-
...objs: (TSource1 | TSource2 | TSource3 | TSource4 | TSource5)[]
29-
) {
27+
export function merge<
28+
TSource1 extends GeneralObject,
29+
TSource2 extends GeneralObject,
30+
TSource3 extends GeneralObject,
31+
TSource4 extends GeneralObject,
32+
TSource5 extends GeneralObject,
33+
>(...objs: (TSource1 | TSource2 | TSource3 | TSource4 | TSource5)[]) {
3034
let final = {};
3135

32-
for (const obj of objs) {
36+
objs.forEach((obj) => {
3337
final = mergeRecursively(final, obj);
34-
}
38+
});
3539

3640
return final;
3741
}

0 commit comments

Comments
 (0)