Skip to content

Commit 4e97be6

Browse files
kaochannel154claude
andcommitted
fix: resolve type error in navigation-list-item.tsx
- Changed from switch statement to if-else chain for better type narrowing - TypeScript now properly narrows the NavigationItem union type - Fixes Vercel deployment build error 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 9a4ba17 commit 4e97be6

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

apps/studio.giselles.ai/app/stage/ui/navigation-rail/navigation-list-item.tsx

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,41 @@ import type { NavigationRailState } from "./types";
66
export function NavigationListItem(
77
props: NavigationItem & { variant: NavigationRailState },
88
) {
9-
switch (props.type) {
10-
case "link":
11-
return (
12-
<Link
13-
href={props.href}
14-
className="text-text-muted text-sm flex items-center py-0.5 hover:bg-ghost-element-hover rounded-lg px-1"
15-
>
16-
<div className="size-8 flex items-center justify-center">
17-
<props.icon className="size-4" />
18-
</div>
19-
{props.variant === "expanded" && props.label}
20-
</Link>
21-
);
22-
case "notification":
23-
return (
24-
<button
25-
type="button"
26-
onClick={(e) => {
27-
const updateButton = e.currentTarget.querySelector("button");
28-
if (updateButton) {
29-
updateButton.click();
30-
}
31-
}}
32-
className="text-text-muted text-sm flex items-center py-0.5 hover:bg-ghost-element-hover rounded-lg px-1 w-full text-left"
33-
>
34-
<div className="size-8 flex items-center justify-center">
35-
<UpdateNotificationButton />
36-
</div>
37-
{props.variant === "expanded" && props.label}
38-
</button>
39-
);
40-
default: {
41-
const _exhaustiveCheck: never = props.type;
42-
throw new Error(`Unhandled type: ${_exhaustiveCheck}`);
43-
}
9+
if (props.type === "link") {
10+
return (
11+
<Link
12+
href={props.href}
13+
className="text-text-muted text-sm flex items-center py-0.5 hover:bg-ghost-element-hover rounded-lg px-1"
14+
>
15+
<div className="size-8 flex items-center justify-center">
16+
<props.icon className="size-4" />
17+
</div>
18+
{props.variant === "expanded" && props.label}
19+
</Link>
20+
);
4421
}
22+
23+
if (props.type === "notification") {
24+
return (
25+
<button
26+
type="button"
27+
onClick={(e) => {
28+
const updateButton = e.currentTarget.querySelector("button");
29+
if (updateButton) {
30+
updateButton.click();
31+
}
32+
}}
33+
className="text-text-muted text-sm flex items-center py-0.5 hover:bg-ghost-element-hover rounded-lg px-1 w-full text-left"
34+
>
35+
<div className="size-8 flex items-center justify-center">
36+
<UpdateNotificationButton />
37+
</div>
38+
{props.variant === "expanded" && props.label}
39+
</button>
40+
);
41+
}
42+
43+
// This should never be reached if NavigationItem is properly typed
44+
const _exhaustiveCheck: never = props;
45+
throw new Error(`Unhandled navigation item type`);
4546
}

0 commit comments

Comments
 (0)