Tag: 明确的

在打字稿中使用指挥官

我尝试在打字稿中使用指挥官,我想给我的气候适当的types。 所以我从这个代码开始: import * as program from "commander"; const cli = program .version("1.0.0") .usage("[options]") .option("-d, –debug", "activate more debug messages. Can be set by env var DEBUG.", false) .parse(process.argv); console.log(cli.debug) 但是我得到这个错误: example.ts(9,17): error TS2339: Property 'debug' does not exist on type 'Command'. 所以我试着添加一个接口,如下所述: import * as program from "commander"; interface InterfaceCLI extends commander.Command { debug?: […]