From 4c1250b2cb3839e3b3934111915459a69f9e50b5 Mon Sep 17 00:00:00 2001 From: Valentino Zegna Date: Mon, 21 Sep 2026 09:53:32 -0700 Subject: [PATCH] fix: narrow clack cancellations past a unique symbol 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(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` 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) Claude-Session: https://claude.ai/code/session_011Ft4s2sjp46Rik8zjbaawf --- src/cli/commands.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cli/commands.ts b/src/cli/commands.ts index 89e4d3a..77a7048 100644 --- a/src/cli/commands.ts +++ b/src/cli/commands.ts @@ -82,8 +82,13 @@ MORE INFO: /** * Check if a clack prompt was cancelled (Ctrl+C). + * + * Narrows with `Exclude` rather than taking `T | symbol`. Clack + * types its cancel value as a `unique symbol`, which does not bind to a plain + * `symbol` slot, so inference used to hand `T` the whole union and the + * assertion narrowed nothing. */ -function assertNotCancelled(value: T | symbol): asserts value is T { +function assertNotCancelled(value: T): asserts value is Exclude { if (clack.isCancel(value)) { clack.cancel("Setup cancelled."); process.exit(0);