Skip to content

Commit

Permalink
fix: Add temporary type guard
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Sep 10, 2024
1 parent 5575c3c commit c978bb3
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ComponentType, IndexedNode } from "@opensystemslab/planx-core/types";
import { Calculate } from "@planx/components/Calculate/model";
import { FileUploadAndLabel } from "@planx/components/FileUploadAndLabel/model";
import { List } from "@planx/components/List/model";
import { QuestionField } from "@planx/components/shared/Schema/model";
import { SearchResult } from "hooks/useSearch";
import { capitalize, get } from "lodash";
import { SLUGS } from "pages/FlowEditor/data/types";
Expand Down Expand Up @@ -74,7 +75,8 @@ const DISPLAY_DATA: Partial<ComponentMap> = {
getHeadline: ({ item, refIndex }) => {
// Fuse.js flattens deeply nested arrays when using refIndex
const options = (item.data as unknown as List).schema.fields
.filter((field) => field.type === "question")
// TODO: Remove type guard when bumping to TS v5.5
.filter((field): field is QuestionField => field.type === "question")
.flatMap((field) => field.data.options);
return options[refIndex].data.val || "";
},
Expand Down

0 comments on commit c978bb3

Please sign in to comment.