Skip to content

Commit 65c989f

Browse files
authored
chore(zbugs): tighten up types on enumerations (rocicorp#4472)
1 parent b10dd71 commit 65c989f

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

apps/zbugs/shared/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const authDataSchema = v.object({
1414
});
1515

1616
export type AuthData = v.Infer<typeof authDataSchema>;
17+
export type Role = AuthData['role'];
1718

1819
export function assertIsLoggedIn(
1920
authData: AuthData | undefined,

apps/zbugs/shared/schema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
type ExpressionBuilder,
1212
type Row,
1313
} from '@rocicorp/zero';
14-
import type {AuthData} from './auth.ts';
14+
import type {AuthData, Role} from './auth.ts';
1515

1616
// Table definitions
1717
const user = table('user')
@@ -20,7 +20,7 @@ const user = table('user')
2020
login: string(),
2121
name: string().optional(),
2222
avatar: string(),
23-
role: enumeration<'user' | 'crew'>(),
23+
role: enumeration<Role>(),
2424
})
2525
.primaryKey('id');
2626

@@ -35,7 +35,7 @@ const issue = table('issue')
3535
creatorID: string(),
3636
assigneeID: string().optional(),
3737
description: string(),
38-
visibility: string(),
38+
visibility: enumeration<'internal' | 'public'>(),
3939
})
4040
.primaryKey('id');
4141

apps/zbugs/src/pages/issue/issue-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ export function IssuePage({onReady}: {onReady: () => void}) {
543543
{login.loginState?.decoded.role === 'crew' ? (
544544
<div className="sidebar-item">
545545
<p className="issue-detail-label">Visibility</p>
546-
<Combobox
546+
<Combobox<'public' | 'internal'>
547547
editable={false}
548548
disabled={!canEdit}
549549
items={[

0 commit comments

Comments
 (0)