Skip to content

feat(core,prompts): export CANCEL_SYMBOL#576

Open
luisangelrod wants to merge 4 commits into
bombshell-dev:mainfrom
luisangelrod:feat/export-cancel-symbol
Open

feat(core,prompts): export CANCEL_SYMBOL#576
luisangelrod wants to merge 4 commits into
bombshell-dev:mainfrom
luisangelrod:feat/export-cancel-symbol

Conversation

@luisangelrod

@luisangelrod luisangelrod commented Jun 24, 2026

Copy link
Copy Markdown

What does this PR do?

Exports CANCEL_SYMBOL from @clack/core and @clack/prompts so consumers can reference the symbol directly without reimplementing it.

Closes #554

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

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-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0d07873

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/core Minor
@clack/prompts Minor

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

Copy link
Copy Markdown

commit: 0d07873

@43081j

43081j commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

please follow the PR template provided rather than whatever your agent output:
https://github.com/bombshell-dev/clack/blob/main/.github/PULL_REQUEST_TEMPLATE.md

i also don't think we need to export the type as it can very easily be inferred via typeof. We were just missing the export of CANCEL_SYMBOL.

@luisangelrod luisangelrod changed the title feat(core,prompts): export CANCEL_SYMBOL and CancelSymbol type feat(core,prompts): export CANCEL_SYMBOL Jun 25, 2026
@luisangelrod

Copy link
Copy Markdown
Author

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.

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

"@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export the cancel symbol

2 participants