From 2b112ad83b87828fb616a5db55a7b06d42b667b0 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 6 Jan 2025 07:53:20 -0400 Subject: [PATCH] tidy up union types so we can reuse the MissingHeadReportSchema typename --- .../queries/PullPageDataQueryOpts.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/PullRequestPage/queries/PullPageDataQueryOpts.tsx b/src/pages/PullRequestPage/queries/PullPageDataQueryOpts.tsx index ec195e78bb..febe602eb5 100644 --- a/src/pages/PullRequestPage/queries/PullPageDataQueryOpts.tsx +++ b/src/pages/PullRequestPage/queries/PullPageDataQueryOpts.tsx @@ -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, @@ -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(), })