【发布时间】:2018-01-23 19:29:05
【问题描述】:
我的 Angular 项目中包含 JS 文件/库,它位于我的资产文件夹中。以前在 Angular 4 或 2 上,我在编译器选项中将 AllowJS 设置为 true 没有问题,但是当我更新到 Angular 5(CLI + Typescript)时它不起作用,它说
error TS5055: Cannot write file '<a path/afile.js>' because it would overwrite input file.
在ng serve or ng build 上仅包含allowJS(我的打字稿文件上没有导入)会触发错误。
此外,删除它成功地服务/构建了我的项目,但我需要 allowJS。
这是我的 tsconfig.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"allowJs": true,
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
这是我的 Angular 版本 + 其他信息
Angular CLI: 1.5.4
Node: 8.9.1
OS: win32 x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router
@angular/cdk: 5.0.0-rc.1-6e865b7
@angular/cli: 1.5.4
@angular/language-service: 4.4.6
@angular/material: 5.0.0-rc.1-6e865b7
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@schematics/angular: 0.1.7
typescript: 2.4.2
webpack: error
【问题讨论】:
-
同样的问题。
-
能否在 github repo 上提供最小的基础项目源产生错误,以便我们重现和检查?
标签: angular typescript