Description
Command
build
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
I have an Angular 15 workspace with a main app and multiple independent projects (aka libraries). For the main app and some projects, I want to set noImplicitAny: true
for the TypeScript compiler, but for some others, I want it to remain false
(the default). The tsconfig.lib.json
files inside the libraries are extending the main tsconfig.json
from the root Angular folder (although I tried removing the extends
as well, no difference, read below).
The problem is, no matter what I do, I keep getting errors about noImplicitAny
from the libraries where it is even explicitly set to false! It seems that the TypeScript compiler disregards the individual tsconfig.lib.json
settings inside those libraries and takes the global setting.
Moreover, I tried moving the setting from the main tsconfig.json
in the root folder, to the app-specific src/tsconfig.app.json
and I still get the same error from the libraries!
These are the other contents of the main tsconfig.json
file:
{
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"module": "es2022",
"target": "es2022",
"lib": ["es2022", "dom"],
"forceConsistentCasingInFileNames": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"moduleResolution": "node",
"emitDecoratorMetadata": false,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"typeRoots": ["node_modules/@types"],
"resolveJsonModule": true,
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
We are not using "full" TypeScript strict mode.
What am I missing?
Minimal Reproduction
This is a repo which reproduces the problem:
https://github.com/digeomel/angular-no-implicit-any
Exception or Error
~ ng build
✔ Browser application bundle generation complete.
Error: projects/test2/src/lib/test2.component.ts:14:25 - error TS7006: Parameter 'param' implicitly has an 'any' type.
14 testMethodWithParam(param) {
~~~~~
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 16.2.4
Node: 18.17.1
Package Manager: npm 10.2.0
OS: win32 x64
Angular: 16.2.8
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1602.4
@angular-devkit/build-angular 16.2.4
@angular-devkit/core 16.2.4
@angular-devkit/schematics 16.2.4
@angular/cli 16.2.4
@schematics/angular 16.2.4
ng-packagr 16.2.3
rxjs 7.8.1
typescript 5.1.6
zone.js 0.13.3
Anything else relevant?
I posted this issue first on the Typescript repo and I got the answer that this is the expected behaviour, but I thought that maybe the Angular compiler spawns individual, separate processes to compile each project, respecting the tsconfig file in each.
In any case, this seems counter-intuitive to me. If there's a workaround, I'd like to know it.
Here's the issue on the Typescript repo:
microsoft/TypeScript#55983