Skip to content

Commit

Permalink
fix: optional chain and types
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Jun 7, 2024
1 parent ff05224 commit 4095cd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/handlers/shared/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function start(context: Context, issue: Context["payload"]["issue"]
const duration: number | null = calculateDurations(labels).shift() || null;

const { id, login } = sender;
const toCreate = { duration, priceLabel, revision: commitHash.substring(0, 7) };
const toCreate = { duration, priceLabel, revision: commitHash?.substring(0, 7) };

const assignmentComment = await generateAssignmentComment(context, issue.created_at, issue.number, id, duration);
const metadata = structuredMetadata.create<typeof toCreate>("Assignment", toCreate);
Expand Down
7 changes: 4 additions & 3 deletions src/handlers/shared/structured-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { LogLevel } from "../../adapters/supabase/pretty-logs";

type Metadata<T extends object> = T & {
revision: string;
revision?: string;
logMessage?: {
type: LogLevel;
message: string;
type?: LogLevel;
message?: string;
};
[key: string]: unknown;
};

function createStructuredMetadata<T extends object>(className: string, metadata: Metadata<T>) {
Expand Down

0 comments on commit 4095cd3

Please sign in to comment.