Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rich-plants-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clack/prompts": patch
---

chore: use more accurate type to replace any in group select
8 changes: 4 additions & 4 deletions packages/prompts/src/group-multi-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface GroupMultiSelectOptions<Value> extends CommonOptions {
export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) => {
const { selectableGroups = true, groupSpacing = 0 } = opts;
const opt = (
option: Option<Value>,
option: Option<Value> & { group: string | boolean },
state:
| 'inactive'
| 'active'
Expand All @@ -33,12 +33,12 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
| 'group-active-selected'
| 'submitted'
| 'cancelled',
options: Option<Value>[] = []
options: (Option<Value> & { 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) {
Expand Down