@@ -94,7 +94,7 @@ const name = await question("What's your name ?", {
94
94
### ` select() `
95
95
96
96
``` ts
97
- select (message : string , options : SelectOptions ): Promise < string >
97
+ select < T extends string > (message : string , options : SelectOptions < T > ): Promise <T >
98
98
` ` `
99
99
100
100
Scrollable select depending ` maxVisible ` (default ` 8 ` ).
@@ -114,7 +114,7 @@ Use `options.skip` to skip prompt. It will return the first choice.
114
114
### ` multiselect ()`
115
115
116
116
` ` ` ts
117
- multiselect (message : string , options : MultiselectOptions ): Promise < [ string ]>
117
+ multiselect < T extends string > (message : string , options : MultiselectOptions < T > ): Promise <T [ ]>
118
118
` ` `
119
119
120
120
Scrollable multiselect depending ` options .maxVisible ` (default ` 8 ` ).<br>
@@ -196,46 +196,46 @@ export interface AbstractPromptOptions {
196
196
stdin? : Stdin ;
197
197
stdout? : Stdout ;
198
198
message: string ;
199
- sginal? : AbortSignal ;
199
+ skip? : boolean ;
200
+ signal? : AbortSignal ;
200
201
}
201
202
202
- export interface PromptValidator <T = string | string [] | boolean > {
203
- validate: (input : T ) => boolean ;
204
- error: (input : T ) => string ;
203
+ export interface PromptValidator <T extends string | string []> {
204
+ validate: (input : T ) => boolean ;
205
205
}
206
206
207
207
export interface QuestionOptions extends SharedOptions {
208
208
defaultValue? : string ;
209
- validators? : Validator [];
209
+ validators? : PromptValidator < string > [];
210
210
secure? : boolean ;
211
211
}
212
212
213
- export interface Choice {
214
- value: any ;
213
+ export interface Choice < T = any > {
214
+ value: T ;
215
215
label: string ;
216
216
description? : string ;
217
217
}
218
218
219
- export interface SelectOptions extends SharedOptions {
220
- choices: (Choice | string )[];
219
+ export interface SelectOptions < T extends string > extends AbstractPromptOptions {
220
+ choices: (Choice < T > | T )[];
221
221
maxVisible? : number ;
222
- ignoreValues? : (string | number | boolean )[];
223
- validators? : Validator [];
222
+ ignoreValues? : (T | number | boolean )[];
223
+ validators? : PromptValidator < string > [];
224
224
autocomplete? : boolean ;
225
225
caseSensitive? : boolean ;
226
226
}
227
227
228
- export interface MultiselectOptions extends SharedOptions {
229
- choices: (Choice | string )[];
228
+ export interface MultiselectOptions < T extends string > extends AbstractPromptOptions {
229
+ choices: (Choice < T > | T )[];
230
230
maxVisible? : number ;
231
- preSelectedChoices? : (Choice | string )[];
232
- validators? : Validator [];
231
+ preSelectedChoices? : (Choice < T > | T )[];
232
+ validators? : PromptValidator < string []> [];
233
233
autocomplete? : boolean ;
234
234
caseSensitive? : boolean ;
235
235
showHint? : boolean ;
236
236
}
237
237
238
- export interface ConfirmOptions extends SharedOptions {
238
+ export interface ConfirmOptions extends AbstractPromptOptions {
239
239
initial? : boolean ;
240
240
}
241
241
` ` `
0 commit comments