fix: narrow clack cancellations past a unique symbol - #48
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mainis red with eight type errors insrc/cli/commands.ts, a file nobody edited.CI runs
npm installandpackage-lock.jsonis gitignored, so dependency ranges resolve fresh on every run.@clack/prompts@^1.1.0has moved from 1.1.0 to 1.8.1, where the cancel value is typed as aunique symbolinstead of a plainsymbol.assertNotCancelled<T>(value: T | symbol): asserts value is Tdepended onsymbolbinding that slot exactly. Aunique symboldoes not bind it, soTinferred as the whole union and the assertion narrowed nothing. Every prompt result stayedstring | unique symboland failed at each use site.Taking
Twhole and assertingExclude<T, symbol>narrows identically under both versions.Verified locally against the version CI actually installs (1.8.1):
The underlying exposure is separate and left alone: with the lockfile ignored, any dependency's next minor can turn
mainred 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