Bru*_*oLM 4 node.js typescript
我的应用程序上有以下代码:
import commander = require('commander');
commander
.option('-u, --user [user]', 'user code')
.option('-p, --pass [pass]', 'pass code')
.parse(process.argv);
Run Code Online (Sandbox Code Playgroud)
然后我尝试访问:
commander.user
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误(来自DefinitelyTyped的commander.d.ts):
user does not exist on type IExportedCommand
Run Code Online (Sandbox Code Playgroud)
我尝试添加这个
interface IExportedCommand {
user: string;
pass: string;
}
Run Code Online (Sandbox Code Playgroud)
但我仍然得到错误.我怎样才能解决这个问题?
commander-expansion.d.ts使用以下内容创建文件:
declare namespace commander {
interface IExportedCommand extends ICommand {
user: string;
pass: string;
}
}
Run Code Online (Sandbox Code Playgroud)
因为我最近做了这样的事情,推荐--auth user:password.保存您处理用户丢失的用户名或密码.但是阻止使用:密码属性
¯\_(?)_/¯
更多:https://github.com/alm-tools/alm/blob/master/src/server/commandLine.ts#L24
| 归档时间: |
|
| 查看次数: |
2033 次 |
| 最近记录: |