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
importconsolafrom"consola";import{defineCommand,createMain}from"../src";constcommand=defineCommand({meta: {name: "hello",version: "1.0.0",description: "My Awesome CLI App",},args: {name: {type: "positional",description: "Your name",required: true,},friendly: {type: "boolean",description: "Use friendly greeting",},age: {type: "number",description: "Your age",required: false,},adj: {type: "enum",description: "Adjective to use in greeting",options: ["awesome","cool","nice"],default: "awesome",required: false,},},run({ args }){consola.log(args);constmsg=[args.friendly ? "Hi" : "Greetings",args.adj||"",args.name,args.age ? `You are ${args.age} years old.` : "",].filter(Boolean).join(" ");consola.log(msg);},});createMain(command)({});
Describe the bug
There are two errors on type:
args.adj should be string or string | number but now it is string[], in further it had better to be 'awesome' | 'cool' | 'nice'
friendly could be undefined if not provided, but here typescript think it is non-nullable
(although age is not required, it will throw an error Invalid value for argument: --age (undefined). Expected a number. if not provided age. It is not related to this issue)
Additional context
I will have a pr to fix the problem.
Logs
No response
The text was updated successfully, but these errors were encountered:
Environment
Reproduction
just use
~/playground/hello.ts
Here is a copy:
Describe the bug
There are two errors on type:
args.adj
should bestring
orstring | number
but now it isstring[]
, in further it had better to be'awesome' | 'cool' | 'nice'
friendly
could be undefined if not provided, but here typescript think it is non-nullable(although
age
is not required, it will throw an errorInvalid value for argument: --age (undefined). Expected a number.
if not provided age. It is not related to this issue)Additional context
I will have a pr to fix the problem.
Logs
No response
The text was updated successfully, but these errors were encountered: