Skip to content

Commit 49a06b7

Browse files
authored
Merge pull request #867 from jsonwebtoken/fix-signing-algorithm
Add type assertion function for grouped options type
2 parents ec40bf3 + ad441b0 commit 49a06b7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/features/common/components/debugger-picker/debugger-picker.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styles from "./debugger-picker.module.scss";
33
import Select, { SingleValue, OptionsOrGroups, GroupBase } from "react-select";
44
import { DebuggerPickerOptionModel } from "@/features/common/models/debugger-picker-option.model";
55
import { LibraryFilterLabel } from "@/features/libraries/models/library-filters.model";
6+
import { isGroupedOptionsType } from "./utils";
67

78

89
interface PickerLabelProps {
@@ -16,7 +17,7 @@ const getGroupLabel = (
1617
>,
1718
selected: DebuggerPickerOptionModel
1819
): LibraryFilterLabel | undefined => {
19-
if (!Array.isArray(options)) return undefined;
20+
if(!isGroupedOptionsType(options)) return undefined
2021

2122
const group = (options as GroupBase<DebuggerPickerOptionModel>[]).find(
2223
(group) => group.options.some((opt) => opt.value === selected.value)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { GroupBase, OptionsOrGroups } from "react-select";
2+
import { DebuggerPickerOptionModel } from "../../models/debugger-picker-option.model";
3+
4+
export const isGroupedOptionsType = (
5+
options: OptionsOrGroups<
6+
DebuggerPickerOptionModel,
7+
GroupBase<DebuggerPickerOptionModel>
8+
>
9+
): options is GroupBase<DebuggerPickerOptionModel>[] => {
10+
return "options" in options[0]
11+
};

0 commit comments

Comments
 (0)