Environment
- OS: macOS
- Node Version: v24.20.0
- Package:
@clack/core, @clack/prompts
- Package Version: core 1.5.0, prompts 1.8.0
Describe the bug
#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';
const p = await path({ 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.
Environment
@clack/core,@clack/promptsDescribe the bug
#592 changed
isCancelfromvalue is symboltovalue is typeof CANCEL_SYMBOL, but every prompt still returnsPromise<T | symbol>(corePrompt.prompt()and the 11as Promise<... | symbol>casts in prompts). typescript can't subtract a unique symbol fromsymbol, so after the guard the result still hassymbolin its type and any downstream use errors. this breaks code that type-checked fine on 1.7.0.To Reproduce
same snippet passes on
prompts 1.7.0/core 1.4.3. assigning the result to a string fails with TS2322 instead.Expected behavior
isCancelnarrows 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.