tsc --watch 在 tsconfig.json 中存在 outDir 时不更新文件

Arn*_*ism 5 typescript tsc tsconfig

我正在尝试使用 Typescript 编写一个 nodejs 命令行应用程序,并且我有以下 tsconfig 文件:

{
"compilerOptions": {
    "module": "commonjs",
    "outDir": "dist"
},
"include": ["src/*.ts"]
}
Run Code Online (Sandbox Code Playgroud)

当我使用tsc一切正常时(*.js 文件出现在 dist 文件夹中)。

但是,当我运行时tsc -w,js 文件首先在 dist 文件夹中创建,但在我更改任何 ts 文件时不会更新。Tsc 似乎可以很好地查看和编译更改,但无法编写实际的 js 文件。

4:23:04 PM - File change detected. Starting incremental compilation...
4:23:04 PM - Compilation complete. Watching for file changes.
Run Code Online (Sandbox Code Playgroud)

当我从 tsconfig 中省略 outDir 参数时,一切正常(更改 ts 文件时正在更新 js 文件)。这不是理想的解决方案,因为我希望 js 输出位于 dist 文件夹而不是 src 中。

当我跳过使用 tsconfig.json 文件并直接运行它时,它也能正常工作:

tsc -w --outDir dist src/app.ts
Run Code Online (Sandbox Code Playgroud)

难道我做错了什么?

在 win10、tsc 2.6.2、节点 7.9.0 上运行

Arn*_*ism 4

我想我已经弄清楚了。

Typescript 2.6 附带了新的 --watch 实现。当降级到 2.5.3 时一切正常。

所以这似乎是新的 --watch 东西在特定条件下出现的问题(win10,在 tsconfig 中使用 outDir)。

将其报告为 Typescript 问题跟踪器中的错误 - https://github.com/Microsoft/TypeScript/issues/20739