【问题标题】:Typescript tsc -w command not watching for file changesTypescript tsc -w 命令不监视文件更改
【发布时间】:2016-11-09 14:14:02
【问题描述】:

我目前正在尝试配置我的应用程序以监视 Typescript 中的任何文件更改,然后在发生这种情况时重新编译并重新启动服务器。这是我的 tsconfig.json:

{
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "rootDir" : "assets/app",
    "outDir": "../public/js/app"
  },
  "files": [
    "./assets/app/*"
  ],
  "exclude": [
    "node_modules"
  ],
  "atom": {
    "rewriteTsconfig": true
  }
}

如您所见,我设置了 rootDir(保存 .ts 文件的位置)并设置了输出目录(存储转译代码的位置)。

这是我的文件结构:

现在,当我尝试运行 tsc -w 命令时,出现以下错误:

error TS6053: File 'assets/app/*.ts' not found.

这表明 tsconfig.json 文件没有正确解析 rootDir 文件夹中的 ts 文件。我试过改变这个,但似乎没有任何效果。有人有什么想法吗?

谢谢!

【问题讨论】:

    标签: typescript angular


    【解决方案1】:

    不确定原子编辑器的情况如何,因为它们有一些不同的设置,但据我所知,您不能将filesexclude 一起使用。因为您已经指向rootDir,所以files 选项是多余的,应该删除

    【讨论】:

    • 嗨,这似乎让我的观察者开始运行,但我现在遇到了另一个错误。我得到了很多这些并且代码没有被编译:public/js/vendor/@angular/router/esm/src/facade/exceptions.d.ts(22,27): error TS1005: ';'预期的。 public/js/vendor/@angular/router/esm/src/facade/exceptions.d.ts(23,14): 错误 TS1005: '=' 预期。 public/js/vendor/@angular/router/esm/src/facade/exceptions.d.ts(23,21): 错误 TS1005: ';'预计。
    • 您也应该将public/js/vendor 目录添加到您的exclude
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-17
    • 2013-06-19
    • 1970-01-01
    • 2012-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多