Skip to content

Commit

Permalink
tidy up union types so we can reuse the MissingHeadReportSchema typename
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov committed Jan 6, 2025
1 parent 307a1a9 commit 2b112ad
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pages/PullRequestPage/queries/PullPageDataQueryOpts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const BundleAnalysisReportSchema = z.object({
isCached: z.boolean(),
})

const BundleAnalysisReportUnion = z.discriminatedUnion('__typename', [
BundleAnalysisReportSchema,
z.object({ __typename: MissingHeadReportSchema.shape.__typename }),
])

const BundleAnalysisComparisonResult = z.union([
z.literal('BundleAnalysisComparison'),
FirstPullRequestSchema.shape.__typename,
Expand Down Expand Up @@ -53,12 +58,7 @@ const RepositorySchema = z.object({
commitid: z.string(),
bundleAnalysis: z
.object({
bundleAnalysisReport: z
.discriminatedUnion('__typename', [
BundleAnalysisReportSchema,
z.object({ __typename: z.literal('MissingHeadReport') }),
])
.nullable(),
bundleAnalysisReport: BundleAnalysisReportUnion.nullable(),
})
.nullable(),
})
Expand Down

0 comments on commit 2b112ad

Please sign in to comment.