Skip to content
Open
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
6 changes: 6 additions & 0 deletions .changeset/lucky-plums-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@clack/core": patch
"@clack/prompts": patch
---

Return type for prompts now correctly specifies `CANCEL_SYMBOL` instead of `symbol`
2 changes: 1 addition & 1 deletion packages/core/src/prompts/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default class Prompt<TValue> {
}

public prompt() {
return new Promise<TValue | symbol | undefined>((resolve) => {
return new Promise<TValue | typeof CANCEL_SYMBOL | undefined>((resolve) => {
if (this._abortSignal) {
if (this._abortSignal.aborted) {
this.state = 'cancel';
Expand Down
6 changes: 3 additions & 3 deletions packages/prompts/src/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styleText } from 'node:util';
import type { Validate } from '@clack/core';
import type { CANCEL_SYMBOL, Validate } from '@clack/core';
import { AutocompletePrompt, settings } from '@clack/core';
import {
type CommonOptions,
Expand Down Expand Up @@ -268,7 +268,7 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
});

// Return the result or cancel symbol
return prompt.prompt() as Promise<Value | symbol>;
return prompt.prompt() as Promise<Value | typeof CANCEL_SYMBOL>;
};

/**
Expand Down Expand Up @@ -452,5 +452,5 @@ export const autocompleteMultiselect = <Value>(opts: AutocompleteMultiSelectOpti
});

// Return the result or cancel symbol
return prompt.prompt() as Promise<Value[] | symbol>;
return prompt.prompt() as Promise<Value[] | typeof CANCEL_SYMBOL>;
};
3 changes: 2 additions & 1 deletion packages/prompts/src/confirm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { styleText } from 'node:util';
import type { CANCEL_SYMBOL } from '@clack/core';
import { ConfirmPrompt, settings, wrapTextWithPrefix } from '@clack/core';
import {
type CommonOptions,
Expand Down Expand Up @@ -107,5 +108,5 @@ export const confirm = (opts: ConfirmOptions) => {
}
}
},
}).prompt() as Promise<boolean | symbol>;
}).prompt() as Promise<boolean | typeof CANCEL_SYMBOL>;
};
4 changes: 2 additions & 2 deletions packages/prompts/src/date.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styleText } from 'node:util';
import type { DateFormat, State, Validate } from '@clack/core';
import type { CANCEL_SYMBOL, DateFormat, State, Validate } from '@clack/core';
import { DatePrompt, runValidation, settings } from '@clack/core';
import { type CommonOptions, S_BAR, S_BAR_END, symbol } from './common.js';

Expand Down Expand Up @@ -133,7 +133,7 @@ export const date = (opts: DateOptions) => {
}
}
},
}).prompt() as Promise<Date | symbol>;
}).prompt() as Promise<Date | typeof CANCEL_SYMBOL>;
};

function renderDate(prompt: Omit<InstanceType<typeof DatePrompt>, 'prompt'>, state: State): string {
Expand Down
3 changes: 2 additions & 1 deletion packages/prompts/src/group-multi-select.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { styleText } from 'node:util';
import type { CANCEL_SYMBOL } from '@clack/core';
import { GroupMultiSelectPrompt, settings, wrapTextWithPrefix } from '@clack/core';
import {
type CommonOptions,
Expand Down Expand Up @@ -315,5 +316,5 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
}
}
},
}).prompt() as Promise<Value[] | symbol>;
}).prompt() as Promise<Value[] | typeof CANCEL_SYMBOL>;
};
3 changes: 2 additions & 1 deletion packages/prompts/src/multi-line.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { styleText } from 'node:util';
import type { CANCEL_SYMBOL } from '@clack/core';
import { MultiLinePrompt, settings, wrapTextWithPrefix } from '@clack/core';
import { S_BAR, S_BAR_END, symbol } from './common.js';
import type { TextOptions } from './text.js';
Expand Down Expand Up @@ -98,5 +99,5 @@ export const multiline = (opts: MultiLineOptions) => {
}
}
},
}).prompt() as Promise<string | symbol>;
}).prompt() as Promise<string | typeof CANCEL_SYMBOL>;
};
3 changes: 2 additions & 1 deletion packages/prompts/src/multi-select.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { styleText } from 'node:util';
import type { CANCEL_SYMBOL } from '@clack/core';
import { MultiSelectPrompt, settings, wrapTextWithPrefix } from '@clack/core';
import {
type CommonOptions,
Expand Down Expand Up @@ -204,5 +205,5 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
}
}
},
}).prompt() as Promise<Value[] | symbol>;
}).prompt() as Promise<Value[] | typeof CANCEL_SYMBOL>;
};
4 changes: 2 additions & 2 deletions packages/prompts/src/password.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styleText } from 'node:util';
import type { Validate } from '@clack/core';
import type { CANCEL_SYMBOL, Validate } from '@clack/core';
import { PasswordPrompt, settings } from '@clack/core';
import { type CommonOptions, S_BAR, S_BAR_END, S_PASSWORD_MASK, symbol } from './common.js';

Expand Down Expand Up @@ -88,5 +88,5 @@ export const password = (opts: PasswordOptions) => {
}
}
},
}).prompt() as Promise<string | symbol>;
}).prompt() as Promise<string | typeof CANCEL_SYMBOL>;
};
3 changes: 2 additions & 1 deletion packages/prompts/src/select-key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { styleText } from 'node:util';
import type { CANCEL_SYMBOL } from '@clack/core';
import { SelectKeyPrompt, settings, wrapTextWithPrefix } from '@clack/core';
import { type CommonOptions, S_BAR, S_BAR_END, symbol } from './common.js';
import type { Option } from './select.js';
Expand Down Expand Up @@ -83,5 +84,5 @@ export const selectKey = <Value extends string>(opts: SelectKeyOptions<Value>) =
}
}
},
}).prompt() as Promise<Value | symbol>;
}).prompt() as Promise<Value | typeof CANCEL_SYMBOL>;
};
3 changes: 2 additions & 1 deletion packages/prompts/src/select.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { styleText } from 'node:util';
import type { CANCEL_SYMBOL } from '@clack/core';
import { SelectPrompt, settings, wrapTextWithPrefix } from '@clack/core';
import {
type CommonOptions,
Expand Down Expand Up @@ -182,5 +183,5 @@ export const select = <Value>(opts: SelectOptions<Value>) => {
}
}
},
}).prompt() as Promise<Value | symbol>;
}).prompt() as Promise<Value | typeof CANCEL_SYMBOL>;
};
4 changes: 2 additions & 2 deletions packages/prompts/src/text.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styleText } from 'node:util';
import type { Validate } from '@clack/core';
import type { CANCEL_SYMBOL, Validate } from '@clack/core';
import { settings, TextPrompt } from '@clack/core';
import { type CommonOptions, S_BAR, S_BAR_END, symbol } from './common.js';

Expand Down Expand Up @@ -107,5 +107,5 @@ export const text = (opts: TextOptions) => {
}
}
},
}).prompt() as Promise<string | symbol>;
}).prompt() as Promise<string | typeof CANCEL_SYMBOL>;
};
Loading