我收到以下错误:
我的tsconfig.json
文件
{
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
//"outFile": "./dist/out-tsc",
"outDir": "./dist",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
// "exclude": [
// "node_modules"
// ],
"lib": [
"es2017",
"dom"
]
}
}
我的tsconfig.app.json
文件:
"extends": "../tsconfig.json",
"compilerOptions": {
"allowJs": true,
//"noEmit": true,
//"outFile": "../out-tsc/app",
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"node_modules",
"public",
"test.ts",
"**/*.spec.ts"
]
如果未注释的noEmit
项目成功运行,但它是空的。
Angular CLI: 1.6.0
Node: 8.9.1
OS: win32 x64
Angular: 5.1.0
angular/cli: 1.6.0
angular-devkit/build-optimizer: 0.0.35
angular-devkit/core: 0.0.22
angular-devkit/schematics: 0.0.41
ngtools/json-schema: 1.1.0
ngtools/webpack: 1.9.0
schematics/angular: 0.1.10
schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.10.0
这个tsconfig对我有用:
{
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
"outDir": "./out-tsc",
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"traceResolution": true,
"target": "es5",
"baseUrl": "./src",
"paths": {
// APP
"app/*": ["./app/*"],
"components/*": ["./app/components/*"],
"services/*": ["./app/services/*"],
"global/*": ["./app/global/*"],
// ASSETS
"assets/*": ["./assets/*"],
// SHARED
"shared/*": ["./shared/*"],
"abstract/*": ["./shared/abstract/*"],
"interfaces/*": ["./shared/interfaces/*"]
},
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
和tsconfig.app:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
//"../node_modules/**",
"public",
"test.ts",
"**/*.spec.ts"
]
}