【发布时间】:2016-03-13 04:05:06
【问题描述】:
我对 tasks.json 有疑问,我已将其简化为以下内容。
在我的 Visual Studio Code 项目的根目录中,文件资源管理器侧边栏中清晰可见的根文件夹是 .vscode,而 .vscode 内部是 tasks.json。这是 VSCode 为我自动生成的,我没有移动文件夹或项目或将 VSCode 指向其他文件夹。
tasks.json的内容如下:
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "tsc",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// args is the HelloWorld program to compile.
"args": ["test.ts"],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
请注意,"args" 的原始默认值是 ["HelloWorld.ts"],但我只是将其更改为 ["test.ts"]。
现在,当我按下 ctrl-shift-b 时,我得到以下信息:
错误 TS6053:找不到文件“HelloWorld.ts”。
请注意,每次尝试此操作时,我都会清除输出窗口中的输出。看起来 VSCode 忽略了我的 tasks.json 文件并使用了默认设置。
我在 Ubuntu 14.04 上。
【问题讨论】:
-
完整性检查:您已保存文件?关闭/重新打开 VSCode?当您重新打开 tasks.json 时,它不会说 HelloWorld?您的项目中没有其他 .vscode 文件夹或 tasks.json 文件吗?
-
电脑迟钝。我做了无数次所有这些事情。无论如何,在 VSCode 中运行构建会自动保存所有文件。我关闭了 VSCode,重新打开它,文件中仍然有 test.ts 而不是 HelloWorld.ts。无论我做什么,构建时都会出现相同的错误消息,一遍又一遍地破坏 .vscode 文件夹并重新创建它等等。然后我读了你的评论,翻了个白眼,决定重新启动我的整个系统出于恶意。 ;p 燃烧的火烈鸟,讨厌的 tasks.json 文件神秘地恢复并显示 ["HelloWorld.ts"]。我将其更改为 ["test.ts"] 并且效果很好。
-
VSCode/TypeScript 有没有其他的地雷你想让我准备好?
标签: typescript visual-studio-code