@@ -169,18 +169,18 @@ export const confirm = (opts: ConfirmOptions) => {
169
169
} ;
170
170
171
171
type Primitive = Readonly < string | boolean | number > ;
172
- interface Option < Value extends Primitive > {
173
- value : Value ;
174
- label ?: string ;
175
- hint ?: string ;
176
- }
177
- export interface SelectOptions < Options extends Option < Value > [ ] , Value extends Primitive > {
172
+
173
+ type Option < Value > = Value extends Primitive
174
+ ? { value : Value ; label ?: string ; hint ?: string }
175
+ : { value : Value ; label : string ; hint ?: string } ;
176
+
177
+ export interface SelectOptions < Options extends Option < Value > [ ] , Value > {
178
178
message : string ;
179
179
options : Options ;
180
180
initialValue ?: Value ;
181
181
}
182
182
183
- export const select = < Options extends Option < Value > [ ] , Value extends Primitive > (
183
+ export const select = < Options extends Option < Value > [ ] , Value > (
184
184
opts : SelectOptions < Options , Value >
185
185
) => {
186
186
const opt = ( option : Option < Value > , state : 'inactive' | 'active' | 'selected' | 'cancelled' ) => {
@@ -269,14 +269,14 @@ export const selectKey = <Options extends Option<Value>[], Value extends string>
269
269
} ) . prompt ( ) as Promise < Value | symbol > ;
270
270
} ;
271
271
272
- export interface MultiSelectOptions < Options extends Option < Value > [ ] , Value extends Primitive > {
272
+ export interface MultiSelectOptions < Options extends Option < Value > [ ] , Value > {
273
273
message : string ;
274
274
options : Options ;
275
275
initialValues ?: Value [ ] ;
276
276
required ?: boolean ;
277
277
cursorAt ?: Value ;
278
278
}
279
- export const multiselect = < Options extends Option < Value > [ ] , Value extends Primitive > (
279
+ export const multiselect = < Options extends Option < Value > [ ] , Value > (
280
280
opts : MultiSelectOptions < Options , Value >
281
281
) => {
282
282
const opt = (
@@ -387,14 +387,14 @@ export const multiselect = <Options extends Option<Value>[], Value extends Primi
387
387
} ) . prompt ( ) as Promise < Value [ ] | symbol > ;
388
388
} ;
389
389
390
- export interface GroupMultiSelectOptions < Options extends Option < Value > [ ] , Value extends Primitive > {
390
+ export interface GroupMultiSelectOptions < Options extends Option < Value > [ ] , Value > {
391
391
message : string ;
392
392
options : Record < string , Options > ;
393
393
initialValues ?: Value [ ] ;
394
394
required ?: boolean ;
395
395
cursorAt ?: Value ;
396
396
}
397
- export const groupMultiselect = < Options extends Option < Value > [ ] , Value extends Primitive > (
397
+ export const groupMultiselect = < Options extends Option < Value > [ ] , Value > (
398
398
opts : GroupMultiSelectOptions < Options , Value >
399
399
) => {
400
400
const opt = (
0 commit comments