Angular 7 | Build--aot失败| Typescript.d.ts声明文件在编译中丢失
我目前正在努力构建最近从v6更新的Angular 7应用程序 运行ng build可以正常工作,但是,启用aot的ng serve-aot、ng build-aot或ng build-prod也会导致以下错误 Typescript编译器无法找到我自己的.d.ts文件,所有文件都位于src/app/types/ 我试图通过将这些文件的路径添加到tsconfig.app.json文件的include属性来解决这个问题,但没有成功 请注意,问题与Angular v6相同Angular 7 | Build--aot失败| Typescript.d.ts声明文件在编译中丢失,angular,typescript,build,angular7,Angular,Typescript,Build,Angular7,我目前正在努力构建最近从v6更新的Angular 7应用程序 运行ng build可以正常工作,但是,启用aot的ng serve-aot、ng build-aot或ng build-prod也会导致以下错误 Typescript编译器无法找到我自己的.d.ts文件,所有文件都位于src/app/types/ 我试图通过将这些文件的路径添加到tsconfig.app.json文件的include属性来解决这个问题,但没有成功 请注意,问题与Angular v6相同 ERROR in ./src/
ERROR in ./src/app/types/data.d.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: /xxx/src/app/types/data.d.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (/xxxx/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:767:23)
at plugin.done.then (/xxxx/node_modules/@ngtools/webpack/src/loader.js:41:31)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
以下是tsconfig.app.json文件:
你能帮我解决这个问题吗?
谢谢。在tsconfig.app.json中将types键更改为typeroot,因为您指定的是文件夹而不是特定文件。我找到了解决问题的方法: 我检查了应用程序中所有.d.ts文件的导入语句。 一个是错误的路径,如果没有-aot标志,这似乎不是问题。 也许这会对某人有所帮助
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": ["node"]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}