【发布时间】:2020-06-13 01:05:21
【问题描述】:
当我遇到一个我不知道如何修复的错误时,我正在为 vscode 编写一个扩展程序。我正在尝试制作一个脚本,在该脚本中根据一些输入创建一个文件,但是当我尝试获取新文件的路径时,它返回一个错误!代码如下:
let command3 = vscode.commands.registerCommand('command-bot.createFile', () => {
var fileName = vscode.window.showInputBox({
placeHolder: "Name your file"
});
var fileExt = vscode.window.showInputBox({
placeHolder: "What is the extention example: .py or .html"
});
const folderPath = vscode.workspace.workspaceFolders[0].uri.toString().split(":")[1];
//The code above caused the error! Error: Object is possibly 'undefined'
});
【问题讨论】:
标签: typescript vscode-extensions