Skip to content

fix: narrow clack cancellations past a unique symbol - #48

Merged
valentinozegna merged 1 commit into
mainfrom
fix/clack-cancel-narrowing
Sep 21, 2026
Merged

valentinozegna merged 1 commit into
mainfrom
fix/clack-cancel-narrowing

Conversation

@valentinozegna

Copy link
Copy Markdown
Contributor

main is red with eight type errors in src/cli/commands.ts, a file nobody edited.

CI runs npm install and package-lock.json is gitignored, so dependency ranges resolve fresh on every run. @clack/prompts@^1.1.0 has moved from 1.1.0 to 1.8.1, where the cancel value is typed as a unique symbol instead of a plain symbol.

assertNotCancelled<T>(value: T | symbol): asserts value is T depended on symbol binding that slot exactly. A unique symbol does not bind it, so T inferred as the whole union and the assertion narrowed nothing. Every prompt result stayed string | unique symbol and failed at each use site.

Taking T whole and asserting Exclude<T, symbol> narrows identically under both versions.

Verified locally against the version CI actually installs (1.8.1):

type-check  8 errors -> 0
lint        clean
test        98 passed, 2 skipped

The underlying exposure is separate and left alone: with the lockfile ignored, any dependency's next minor can turn main red without a commit. Pinning or committing the lockfile is a call for this repository to make.

🤖 Generated with Claude Code

https://claude.ai/code/session_011Ft4s2sjp46Rik8zjbaawf

Eight type errors on main, in a file nobody had edited. CI runs
`npm install` against a gitignored lockfile, so it resolves
`@clack/prompts@^1.1.0` fresh on every run and had moved from 1.1.0 to
1.8.1, where the cancel value is typed as a `unique symbol` rather than
a plain `symbol`.

`assertNotCancelled<T>(value: T | symbol)` relied on `symbol` binding
that slot exactly. A `unique symbol` does not, so `T` absorbed the whole
union and the assertion narrowed nothing: every prompt result stayed
`string | unique symbol` and failed at each use.

Taking `T` whole and asserting `Exclude<T, symbol>` narrows the same way
under both versions. Type check goes 8 errors to 0, lint clean, 98 tests
pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_011Ft4s2sjp46Rik8zjbaawf
@valentinozegna
valentinozegna merged commit 95eec61 into main Sep 21, 2026
2 checks passed
@valentinozegna
valentinozegna deleted the fix/clack-cancel-narrowing branch September 21, 2026 16:54
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.

1 participant