Skip to content

Commit 35d0566

Browse files
fix: resolve remaining TypeScript strict mode violations in MainSection components
- ProfileMenu/sections/MainSection: replace boolean short-circuit + filter(type predicate) with typed items array + conditional spread to avoid TS2677 type predicate error - sidebar/sections/MainSection: cast array to (SidebarMenuItem | undefined)[] before filtering so the type predicate is valid (TS2677: predicate type must be assignable to parameter type) Co-authored-by: Amar Trebinjac <AmarTrebinjac@users.noreply.github.com>
1 parent 2760ad6 commit 35d0566

2 files changed

Lines changed: 37 additions & 33 deletions

File tree

packages/shared/src/components/ProfileMenu/sections/MainSection.tsx

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,37 @@ export const MainSection = (): ReactElement => {
1818
const hasAccessToCores = useHasAccessToCores();
1919
const { user } = useAuthContext();
2020

21-
return (
22-
<ProfileSection
23-
items={[
24-
{
25-
title: 'Your profile',
26-
href: `${webappUrl}${user?.username}`,
27-
icon: UserIcon,
28-
},
29-
hasAccessToCores && {
30-
title: 'Core wallet',
31-
href: walletUrl,
32-
icon: CoinIcon,
33-
},
34-
{
35-
title: 'Achievements',
36-
href: `${webappUrl}${user?.username}/achievements`,
37-
icon: MedalBadgeIcon,
38-
},
39-
{
40-
title: 'DevCard',
41-
href: `${settingsUrl}/customization/devcard`,
42-
icon: DevCardIcon,
43-
},
44-
{
45-
title: 'Analytics',
46-
href: `${webappUrl}analytics`,
47-
icon: AnalyticsIcon,
48-
},
49-
].filter((item): item is ProfileSectionItemProps => !!item)}
50-
/>
51-
);
21+
const items: ProfileSectionItemProps[] = [
22+
{
23+
title: 'Your profile',
24+
href: `${webappUrl}${user?.username}`,
25+
icon: UserIcon,
26+
},
27+
...(hasAccessToCores
28+
? [
29+
{
30+
title: 'Core wallet',
31+
href: walletUrl,
32+
icon: CoinIcon,
33+
} satisfies ProfileSectionItemProps,
34+
]
35+
: []),
36+
{
37+
title: 'Achievements',
38+
href: `${webappUrl}${user?.username}/achievements`,
39+
icon: MedalBadgeIcon,
40+
},
41+
{
42+
title: 'DevCard',
43+
href: `${settingsUrl}/customization/devcard`,
44+
icon: DevCardIcon,
45+
},
46+
{
47+
title: 'Analytics',
48+
href: `${webappUrl}analytics`,
49+
icon: AnalyticsIcon,
50+
},
51+
];
52+
53+
return <ProfileSection items={items} />;
5254
};

packages/shared/src/components/sidebar/sections/MainSection.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const MainSection = ({
116116
}
117117
: undefined;
118118

119-
return [
119+
return ([
120120
myFeed,
121121
{
122122
title: 'Following',
@@ -158,7 +158,9 @@ export const MainSection = ({
158158
gameCenter,
159159
yearInReview,
160160
plusButton,
161-
].filter((item): item is SidebarMenuItem => !!item);
161+
] as (SidebarMenuItem | undefined)[]).filter(
162+
(item): item is SidebarMenuItem => !!item,
163+
);
162164
}, [
163165
ctaCopy,
164166
isCustomDefaultFeed,

0 commit comments

Comments
 (0)