[READ-ONLY] Mirror of https://github.com/bombshell-dev/docs. bomb.sh/docs
0

Configure Feed

Select the types of activity you want to include in your feed.

refactor: enhance examples with isCancel checks and type adjustments

Paul Valladares (Mar 21, 2025, 3:06 PM -0600) 5116ef9e b390c158

+13 -13
+13 -13
src/content/docs/guides/examples.mdx
··· 10 10 ### Simple Text Input 11 11 12 12 ```ts twoslash 13 - import { text } from '@clack/prompts'; 13 + import { text, isCancel } from '@clack/prompts'; 14 14 15 15 const name = await text({ 16 16 message: 'What is your name?', 17 17 placeholder: 'John Doe', 18 - }) as string; 18 + }); 19 19 20 - console.log(`Hello, ${name}!`); 20 + console.log(`Hello, ${isCancel(name)}!`); 21 21 ``` 22 22 23 23 ### Selection Menu ··· 40 40 } 41 41 42 42 // Convert to string before using in template literal 43 - const frameworkStr = String(framework); 43 + const frameworkStr = isCancel(framework); 44 44 console.log(`You selected ${frameworkStr}`); 45 45 ``` 46 46 ··· 75 75 if (value.length === 0) return 'Name is required'; 76 76 return undefined; 77 77 }, 78 - }) as string; 78 + }); 79 79 80 80 const type = await select({ 81 81 message: 'Project type:', ··· 111 111 112 112 // Confirm setup 113 113 const shouldProceed = await confirm({ 114 - message: `Create ${String(type)} project "${name}"${framework ? ` with ${String(framework)}` : ''}?`, 114 + message: `Create ${isCancel(type)} project "${isCancel(name)}"${framework ? ` with ${isCancel(framework)}` : ''}?`, 115 115 }); 116 116 117 117 if (shouldProceed) { ··· 246 246 import { text, select, isCancel } from '@clack/prompts'; 247 247 248 248 interface UserData { 249 - name: string | symbol; 250 - email: string | symbol; 251 - age: number; 249 + name: string; 250 + email: string; 251 + age: string; 252 252 role: string; 253 253 } 254 254 ··· 279 279 if (num < 18 || num > 100) return 'Age must be between 18 and 100'; 280 280 return undefined; 281 281 }, 282 - }); 282 + }) 283 283 284 284 const role = await select({ 285 285 message: 'Select role:', ··· 290 290 ], 291 291 }); 292 292 293 - if (isCancel(role)) { 293 + if (isCancel(role) || isCancel(name) || isCancel(email) || isCancel(age)) { 294 294 console.log('Operation cancelled'); 295 295 process.exit(0); 296 296 } ··· 298 298 return { 299 299 name, 300 300 email, 301 - age: Number(age), 302 - role: String(role), 301 + age, 302 + role, 303 303 }; 304 304 } 305 305 ```