ts: This file is a unit testing file related to app component. This file is used along with other unit tests. It is run from Angular CLI by the command ng test. app.
At the root tsconfig. json file specifies the base TypeScript and Angular compiler options that all projects in the workspace inherit. See the Angular compiler options guide for information about what Angular specific options are available.
It turned out that you need to remove this line from "include"
"src/**/*.ts"
from tsconfig.app.json
and only keep entry points in files (main.ts and polyfills.ts)
I could get it working by defining the files
property in tsconfig.app.json
. These files are relative to the tsconfig.app.json
file.
"files": [
"main.ts",
"polyfills.ts"
]
I had seen these messages complaining about environment.*.ts files which are actually mentioned in angular.json for different builds, after upgrading from Angular 8 to Angular 9 including CLI local and global. However, I did not run ng update
which might update tsconfig.json with the following, instead I updated tsconfig.json manually.
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
Then the warnings disappear.
Update 2020-05-27 with Angular 9.1.x in Visual Studio Professional 2019
The little block above is not needed anymore. Otherwise, it will cause the spec test codes complaining "module not found" against modules which are actually there since ng test
is building and running just fine, and the build and the running of the ng app are OK. Apparently somethings in NG had changed between 9 and 9.1.
Here's my working tsconfig.json now:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2020",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"skipLibCheck": true
}
}
remarks:
I target Google Chrome and Safari only, so if you want to target other browsers, you may need to adjust accordingly.
Updated to Angular 9 today and got warnings. My solution was add this "files" array without the "src" in the path. Just added:
"files": [
"main.ts",
"polyfills.ts"
],
My full tsconfig.app.json file is:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": ["node"]
},
"files": [
"main.ts",
"polyfills.ts"
],
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
I was getting bombarded with these messages in Angular 10 having never seen them before. Changing includes
made no difference.
Then I found https://github.com/angular/angular/pull/36211.
This is essentially the same error as raised in this question but for ngtypecheck.ts
files (whatever they are exactly i'm not sure!)
WARNING in /home/circleci/ng/aio/src/main.ngtypecheck.ts is part of the TypeScript compilation but it's unused. Add only entry points to the 'files' or 'include' properties in your tsconfig.
It looks like for me it's actually to do with @angular-builders/custom-webpack
.
https://github.com/just-jeb/angular-builders/issues/781 where an issue was only just opened. Thanks to https://stackoverflow.com/a/62573294/16940 for pointing this out.
Updating to the v10.0.1 fixed it for me, but see the above issue for the latest.
"@angular-builders/custom-webpack": "10.0.1" // as of today
This may seem obvious, BUT you will see this warning for any file that you add but is not yet referenced/imported into another file. This will become obvious when you attempt to edit one of the files subject to the warning, and Ivy does not automatically recompile after editing the file. Once you import the module into a dependent file and start using it, the warnings go away.
The answers above may be relevant to some, but what I just described in this post was the root cause of my warnings. Note, I do not have an include or files array in my tsconfig.json or tsconfig.app.json and the warnings went away as soon as I actually referenced the files elsewhere in my project.
02-08-2020
Ionic 5+ Angular 9+ App.
Note: see the include
section.
tsconfig.app.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
],
"exclude": [
"src/**/*.spec.ts"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With