简体   繁体   中英

VS2015 Typescript compiler not using the proper config

I have this Typescript project, that must be compiled to AMD and ES3. When I modify a file and save, the compile on save works just fine. However, when I build my solution, it re-compiles everything to commonjs (actually the --module flag is not provided so I just assume this is what's selected) and ES5.

I've checked the .csproj for the proper config

<TypeScriptModuleKind>AMD</TypeScriptModuleKind>

I've added a tsconfig.json at the root and also at the .ts files location without any success.

What am I missing? Why is it using the right config for compile on save but not when I'm building the project? Also, randomly I'm getting the "Build: Cannot compile modules unless the --module flag is provided." error.

I've found out that there is an issue (that is resolved in tsc 1.6) and that the .csproj has to be modified. THe PropertyGroup's condition must be changed to specify one without a platform.

https://github.com/Microsoft/TypeScript/issues/4300

或者,只要您具有指定模块系统和目标ES版本的有效tsconfig.json文件,您就可以选择直接从命令行使用tsc进行编译(可以使用npm install -g typescript tsconfig.json进行安装)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM