Skip to content

Commit 4c89dd7

Browse files
chouchouji43081j
andauthored
chore: use more accurate type to replace any (#369)
Co-authored-by: James Garbutt <[email protected]>
1 parent e0ecdf5 commit 4c89dd7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.changeset/rich-plants-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clack/prompts": patch
3+
---
4+
5+
chore: use more accurate type to replace any in group select

packages/prompts/src/group-multi-select.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface GroupMultiSelectOptions<Value> extends CommonOptions {
2323
export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) => {
2424
const { selectableGroups = true, groupSpacing = 0 } = opts;
2525
const opt = (
26-
option: Option<Value>,
26+
option: Option<Value> & { group: string | boolean },
2727
state:
2828
| 'inactive'
2929
| 'active'
@@ -33,12 +33,12 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
3333
| 'group-active-selected'
3434
| 'submitted'
3535
| 'cancelled',
36-
options: Option<Value>[] = []
36+
options: (Option<Value> & { group: string | boolean })[] = []
3737
) => {
3838
const label = option.label ?? String(option.value);
39-
const isItem = typeof (option as any).group === 'string';
39+
const isItem = typeof option.group === 'string';
4040
const next = isItem && (options[options.indexOf(option) + 1] ?? { group: true });
41-
const isLast = isItem && (next as any).group === true;
41+
const isLast = isItem && next && next.group === true;
4242
const prefix = isItem ? (selectableGroups ? `${isLast ? S_BAR_END : S_BAR} ` : ' ') : '';
4343
let spacingPrefix = '';
4444
if (groupSpacing > 0 && !isItem) {

0 commit comments

Comments
 (0)