You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] isCancel no longer narrows prompt results after 1.5.0 #600
#592 changed isCancel from value is symbol to value is typeof CANCEL_SYMBOL, but every prompt still returns Promise<T | symbol> (core Prompt.prompt() and the 11 as Promise<... | symbol> casts in prompts). typescript can't subtract a unique symbol from symbol, so after the guard the result still has symbol in its type and any downstream use errors. this breaks code that type-checked fine on 1.7.0.
To Reproduce
import{path,isCancel}from'@clack/prompts';constp=awaitpath({message: 'pick a file'});if(isCancel(p))process.exit(0);console.log(`selected: ${p}`);// TS2731: Implicit conversion of a 'symbol' to a 'string' will fail at runtime.
same snippet passes on prompts 1.7.0 / core 1.4.3. assigning the result to a string fails with TS2322 instead.
Expected behavior
isCancel narrows the cancel case away like it did before. #554 asked for the specific cancel type on prompt return types, and #592 only did the guard half, which is what left the two out of sync.
we can revert it but its technically more correct now than it was.
i.e. a prompt currently can't return any symbol without breaking isCancel.
so there's two options:
go back, accept prompts that resolve to symbols can't use isCancel (what we had before)
go forward, change every prompt to be | typeof CANCEL_SYMBOL instead of | symbol
i'm happy to go with whatever you two think is the most sensible one. only really a select can produce a symbol today (select from a list of symbols), so its pretty low risk leaving it as it was (1)
Activity
43081j commentedon Sep 8, 2026
sad times.
i blame the LLM that pushed us to make that change 😞 may just close them in future
lets fix it in a patch. i think we can just update the prompts to return
T | typeof CANCEL_SYMBOLgameroman commentedon Sep 8, 2026
I wonder if we can just revert
isCanceltovalue is symbol?clack/packages/core/src/utils/index.ts
Line 17 in de1ef16
The reason they asked to export
CANCEL_SYMBOLin the original issue was for tests but the other 2 points about "broadsymboltype"43081j commentedon Sep 8, 2026
we can revert it but its technically more correct now than it was.
i.e. a prompt currently can't return any
symbolwithout breakingisCancel.so there's two options:
isCancel(what we had before)| typeof CANCEL_SYMBOLinstead of| symboli'm happy to go with whatever you two think is the most sensible one. only really a
selectcan produce a symbol today (select from a list of symbols), so its pretty low risk leaving it as it was (1)chore(deps): take @clack/prompts 1.8.1 and adapt to its cancel and va…
chore(deps): bump the npm-minor group with 2 updates (#502)