【发布时间】:2021-09-06 07:29:31
【问题描述】:
我最近问了一个问题"how do i add custom parameters to a custom command in a custom vs code extension",通过一些cmets意识到不能在命令面板中输入参数。所以我寻找替代选择。我遇到的一个是 quickInput,它允许用户在窗口中输入文本。然而,作为打字稿的新手,以及拥有更多知识渊博的用户的documentation,我不知道如何使用它。请帮忙!
更新:由于找不到“quickInput”,我决定选择“showInputBox”,但不确定如何使用“title”参数。但只是为了测试 porpuses,我决定测试以下内容:
var info = vscode.window.showInputBox();
vscode.window.showInformationMessage(info);
但它出现了错误:
No overload matches this call.
Overload 1 of 4, '(message: string, ...items: string[]); Thenable<string | undefined>', gave the following error.
Argument of type 'Thenable<string | undefined>' is not assignable to the parameter of type 'string'.
Overload 2 of 4, '(message: string, ...items: MessageItem[]); Thenable<MessageItem | undefined>', gave the following error.
Argument of type 'Thenable<string | undefined>' is not assignable to the parameter of type 'string'. ts(2769) [29, 40]
我注意到它只给出了重载 1 和 2,而不是 3 和 4 无论如何,现在我需要知道如何添加:1)输入框的标题,以及2)如何解决该错误!!!
编辑 2: 我试过这个来解决变量类型问题:
var info = vscode.window.showInputBox();
if(typeof info === "string") {
vscode.window.showInformationMessage(info);
}
它没有出现任何错误,但是......它接受了我的输入并没有发送它。
【问题讨论】:
-
查看扩展示例
-
我没有看到任何例子,但我会再看一遍。
-
上面还写着
cannot find name 'QuickInput'
标签: typescript visual-studio-code vscode-extensions