feat(core,prompts): export CANCEL_SYMBOL#576
Conversation
isCancel() identifies cancellation values but the underlying symbol was not exported, making a few things unnecessarily difficult: - Tests cannot create a synthetic cancel value that behaves like clack's own cancel result without re-implementing the internals - Return types of prompts use the broad `symbol` type rather than a precise branded type - isCancel() narrowed to `symbol` instead of a specific cancel type Fixes bombshell-dev#554 Changes: - Added `CancelSymbol` type alias (`typeof CANCEL_SYMBOL`) in core utils - Updated `isCancel` guard to narrow to `CancelSymbol` instead of `symbol` - Exported `CANCEL_SYMBOL` and `CancelSymbol` from `@clack/core` - Re-exported both from `@clack/prompts` Usage after this change: ```ts import { CANCEL_SYMBOL, isCancel } from '@clack/prompts' import type { CancelSymbol } from '@clack/prompts' const result = await text({ message: 'Name?' }) if (isCancel(result)) { // result is now narrowed to CancelSymbol, not the broad symbol type } // Tests can now create a synthetic cancel without internal knowledge: const cancelled: CancelSymbol = CANCEL_SYMBOL ```
🦋 Changeset detectedLatest commit: 0d07873 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
please follow the PR template provided rather than whatever your agent output: i also don't think we need to export the type as it can very easily be inferred via |
|
Thanks for the feedback. Updated the PR description to follow the template and simplified the change to just export CANCEL_SYMBOL without the explicit type. |
| "@clack/prompts": minor | ||
| --- | ||
|
|
||
| Export `CANCEL_SYMBOL` constant and `CancelSymbol` type from both packages. |
There was a problem hiding this comment.
you can discard this changeset now
| "@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. |
There was a problem hiding this comment.
and this one no longer needs to mention the type
What does this PR do?
Exports
CANCEL_SYMBOLfrom@clack/coreand@clack/promptsso consumers can reference the symbol directly without reimplementing it.Closes #554
Type of change
Checklist
pnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure