我想拥有自己的现有模块实现,但要保持与现有模块的兼容接口.我没有现有模块的模块类型,只有一个接口.所以我不能include Original_module在我的界面中使用.有没有办法从界面获取模块类型?
一个例子可以是Liststdlib中的模块.我创建的My_list模块与签名完全相同List.我可以复制list.mli到my_list.mli,但它似乎不太好.
我尝试在打字稿中使用指挥官,我想为我的 cli 提供正确的类型。所以我从这段代码开始:
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)
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
example.ts(9,17): error TS2339: Property 'debug' does not exist on type 'Command'.
Run Code Online (Sandbox Code Playgroud)
所以我尝试添加一个接口,如此处所述:
import * as program from "commander";
interface InterfaceCLI extends commander.Command {
debug?: boolean;
}
const cli: InterfaceCLI = program
.version("1.0.0")
.usage("[options]")
.option("-d, --debug", "activate more debug messages. Can be set by env var DEBUG.", …Run Code Online (Sandbox Code Playgroud)