diff --git a/.changeset/rich-plants-call.md b/.changeset/rich-plants-call.md new file mode 100644 index 00000000..cdffa94d --- /dev/null +++ b/.changeset/rich-plants-call.md @@ -0,0 +1,5 @@ +--- +"@clack/prompts": patch +--- + +chore: use more accurate type to replace any in group select diff --git a/packages/prompts/src/group-multi-select.ts b/packages/prompts/src/group-multi-select.ts index 7854744b..4464b074 100644 --- a/packages/prompts/src/group-multi-select.ts +++ b/packages/prompts/src/group-multi-select.ts @@ -23,7 +23,7 @@ export interface GroupMultiSelectOptions extends CommonOptions { export const groupMultiselect = (opts: GroupMultiSelectOptions) => { const { selectableGroups = true, groupSpacing = 0 } = opts; const opt = ( - option: Option, + option: Option & { group: string | boolean }, state: | 'inactive' | 'active' @@ -33,12 +33,12 @@ export const groupMultiselect = (opts: GroupMultiSelectOptions) => | 'group-active-selected' | 'submitted' | 'cancelled', - options: Option[] = [] + options: (Option & { group: string | boolean })[] = [] ) => { const label = option.label ?? String(option.value); - const isItem = typeof (option as any).group === 'string'; + const isItem = typeof option.group === 'string'; const next = isItem && (options[options.indexOf(option) + 1] ?? { group: true }); - const isLast = isItem && (next as any).group === true; + const isLast = isItem && next && next.group === true; const prefix = isItem ? (selectableGroups ? `${isLast ? S_BAR_END : S_BAR} ` : ' ') : ''; let spacingPrefix = ''; if (groupSpacing > 0 && !isItem) {