Skip to content

Commit 98925e3

Browse files
authored
Exports Option type (#229)
1 parent 1904e57 commit 98925e3

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

.changeset/orange-olives-yell.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+
Exports the `Option` type and improves JSDocannotations

packages/prompts/src/index.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,43 @@ export const confirm = (opts: ConfirmOptions) => {
209209

210210
type Primitive = Readonly<string | boolean | number>;
211211

212-
type Option<Value> = Value extends Primitive
213-
? { value: Value; label?: string; hint?: string }
214-
: { value: Value; label: string; hint?: string };
212+
export type Option<Value> = Value extends Primitive
213+
? {
214+
/**
215+
* Internal data for this option.
216+
*/
217+
value: Value;
218+
/**
219+
* The optional, user-facing text for this option.
220+
*
221+
* By default, the `value` is converted to a string.
222+
*/
223+
label?: string;
224+
/**
225+
* An optional hint to display to the user when
226+
* this option might be selected.
227+
*
228+
* By default, no `hint` is displayed.
229+
*/
230+
hint?: string;
231+
}
232+
: {
233+
/**
234+
* Internal data for this option.
235+
*/
236+
value: Value;
237+
/**
238+
* Required. The user-facing text for this option.
239+
*/
240+
label: string;
241+
/**
242+
* An optional hint to display to the user when
243+
* this option might be selected.
244+
*
245+
* By default, no `hint` is displayed.
246+
*/
247+
hint?: string;
248+
};
215249

216250
export interface SelectOptions<Value> {
217251
message: string;

0 commit comments

Comments
 (0)