cmd-ts icon indicating copy to clipboard operation
cmd-ts copied to clipboard

Example of extracting handler argument types?

Open everett1992 opened this issue 1 year ago • 1 comments

All the documentation and examples use an inline handler

command({
   args: {
     foo: ...
   },
   handler({foo}) {},
})

but I want to define the function separately because it's

command({
   args: {
     foo: ...
   },
   handler,
})

function handler(args: unknown) {
}

But it doesn't seem possible to get the type for args.

everett1992 avatar Dec 11 '24 20:12 everett1992

Same problem here.

I see this type declaration:

declare type HandlerFunc<Args extends ArgTypes> = (args: Output<Args>) => any;

But the Output type isn't exported. If it were, we could easily extract Output<typeof myCommand["args"]>

NfNitLoop avatar Jun 22 '25 05:06 NfNitLoop