2016-07-07 333 views
0

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

{ 
    "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文件保存),并设置输出目录(其中有transpiled代码存储)。

这里是我的文件结构:

enter image description here

现在,当我尝试运行TSC -w命令我碰到下面的错误:

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

这将表明tsconfig .json文件没有正确解析我的ts文件在rootDir文件夹内。我试图改变这一点,但似乎没有任何工作。有没有人有任何想法?

谢谢!

回答

1

不知道它是如何与原子编辑器,因为他们有一些不同的设置,但据我所知,你不能使用filesexclude。因为你已经指向rootDirfiles选项是多余的,应该删除

+0

嗨,这似乎让我的观察者运行,但我现在遇到了另一个错误。我得到了很多很多这样的代码,并且代码没有得到转发:public/js/vendor/@angular/router/esm/src/facade/exception.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:';'预期。 – devoncrazylegs

+0

你应该把'public/js/vendor'目录加到你的'exclude'中 – PierreDuc

+0

非常感谢你! – devoncrazylegs