commander-js/extra-typings commander 类型安全的玩法

commander-js/extra-typings 提供了类型推理能力,可以进行强类型的cli 命令开发,不少cli 应用都是用了此包

参考玩法

  • app.ts
import { program } from '@commander-js/extra-typings';

program.command('print')
  .argument('<file>')
  .option('--double-sided')
  .action((targetFile, options) => {
    // command-arguments and options are fully typed
  });

说明

希望进行强类型commander cli 开发的(基于ts 的),commander-js/extra-typings 是一个值得使用的包

参考资料

https://github.com/commander-js/extra-typings

posted on 2026-10-17 08:00  荣锋亮  阅读(3)  评论(0)    收藏  举报

导航