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
9 changes: 9 additions & 0 deletions .changeset/bright-wolves-export-cancel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@clack/core": minor
"@clack/prompts": minor
---

Export `CANCEL_SYMBOL` constant and `CancelSymbol` type from both packages.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can discard this changeset now


This allows consumers to create synthetic cancel values in tests and write
precise TypeScript types without reimplementing internals.
6 changes: 6 additions & 0 deletions .changeset/shaggy-boxes-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@clack/core": minor
"@clack/prompts": minor
---

Export `CANCEL_SYMBOL` constant and `CancelSymbol` type from `@clack/core` and `@clack/prompts`. Update `isCancel` type guard to narrow to `CancelSymbol` instead of the broad `symbol` type.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this one no longer needs to mention the type

2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export { default as SelectKeyPrompt } from './prompts/select-key.js';
export type { TextOptions } from './prompts/text.js';
export { default as TextPrompt } from './prompts/text.js';
export type { ClackState as State } from './types.js';
export { block, getColumns, getRows, isCancel, wrapTextWithPrefix } from './utils/index.js';
export { block, getColumns, getRows, isCancel, CANCEL_SYMBOL, wrapTextWithPrefix } from './utils/index.js';
export type { ClackSettings } from './utils/settings.js';
export { settings, updateSettings } from './utils/settings.js';
export type { Validate } from './utils/validation.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const isWindows = globalThis.process.platform.startsWith('win');

export const CANCEL_SYMBOL = Symbol('clack:cancel');

export function isCancel(value: unknown): value is symbol {
export function isCancel(value: unknown): value is typeof CANCEL_SYMBOL {
return value === CANCEL_SYMBOL;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type { ClackSettings } from '@clack/core';
export { isCancel, settings, updateSettings } from '@clack/core';
export { isCancel, CANCEL_SYMBOL, settings, updateSettings } from '@clack/core';

export * from './autocomplete.js';
export * from './box.js';
Expand Down
Loading