From ef57eecdaac3bb528d41d2f82a98875d83167535 Mon Sep 17 00:00:00 2001 From: Carson Full Date: Mon, 23 Oct 2023 21:20:08 -0500 Subject: [PATCH] Fix `OptionGroup` type now that schema has more properties (#1487) Now it's actually based on keys defined in the groups array, which is more appropriate, rather than assuming "all required props." This is possible by switching the groups type to a satisfies clause, which wasn't available when the code was first written. --- .../Steps/ExplanationOfProgress/ExplanationOfProgress.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx b/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx index 55393caa40..8ff338b7fe 100644 --- a/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx +++ b/src/scenes/ProgressReports/EditForm/Steps/ExplanationOfProgress/ExplanationOfProgress.tsx @@ -6,7 +6,6 @@ import onFieldChange from 'final-form-calculate'; import { camelCase } from 'lodash'; import { DateTime } from 'luxon'; import { useMemo, useState } from 'react'; -import { RequiredKeysOf } from 'type-fest'; import type { ProgressReportVarianceExplanationReasonOptions as ReasonOptions } from '~/api/schema.graphql'; import { canEditAny } from '~/common'; import { @@ -23,9 +22,11 @@ import { VarianceExplanation } from '../../../Detail/VarianceExplanation/Varianc import { StepComponent } from '../step.types'; import { ExplainProgressVarianceDocument } from './ExplanationOfProgress.graphql'; -type OptionGroup = RequiredKeysOf; +type OptionGroup = typeof groups extends Array ? T : never; -const groups: OptionGroup[] = ['behind', 'onTime', 'ahead']; +const groups = ['behind', 'onTime', 'ahead'] satisfies Array< + keyof ReasonOptions +>; const decorators: Array> = [ onFieldChange({