I have encountered difficulties in building my Angular 7 application after upgrading from v6.
When I use ng build
, everything runs smoothly. However, when I try either ng serve --aot
, ng build --aot
, or ng build --prod
(which also includes aot), an error occurs as shown below.
The TypeScript compiler is unable to locate my custom .d.ts
files stored in src/app/types/
.
I attempted to resolve this by adding the file paths to the include
property within the tsconfig.app.json
file, but it didn't work.
It's worth noting that I faced the same issue with Angular v6.
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)
This is the content of the tsconfig.json
file :
{
"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"
]
}
}
This is the content of the tsconfig.app.json
file :
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": ["node"]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
I would greatly appreciate any assistance you can provide in resolving this issue. Thank you.