Ever since I've upgraded my app to the latest version of Angular (18.2.0), I'm getting this warning message in many of the components:
Imports array contains unused imports(-998113)
Now, I understand the meaning of this and why it's showing up like that, and basically it's great that it exists, to let me know (although it doesn't say which import(s) are not used!). But nevertheless, I don't want it to appear, and without removing unused imports.
Is there a setting or a configuration that I can use to stop getting these warning message?
Ever since I've upgraded my app to the latest version of Angular (18.2.0), I'm getting this warning message in many of the components:
Imports array contains unused imports(-998113)
Now, I understand the meaning of this and why it's showing up like that, and basically it's great that it exists, to let me know (although it doesn't say which import(s) are not used!). But nevertheless, I don't want it to appear, and without removing unused imports.
Is there a setting or a configuration that I can use to stop getting these warning message?
Share Improve this question edited Nov 19, 2024 at 11:32 Naren Murali 61.1k5 gold badges44 silver badges81 bronze badges asked Nov 19, 2024 at 11:12 TheCuBeManTheCuBeMan 2,5034 gold badges27 silver badges41 bronze badges 6 | Show 1 more comment2 Answers
Reset to default 5You can try upgrading the plugin Angular Language Service
to the latest version and probably turn on the auto update
checkbox (so that the plugin always has the latest version). If that does not work out try the below suggestion.
This seems to be present in the documentation under:
NG8113 - Unused Standalone Imports
This diagnostic detects cases where the imports array of a @Component contains symbols that aren't used within the template.
Check if there are any imports that you are not using.
@Component({
imports: [UsedDirective, UnusedPipe]
})
class AwesomeCheckbox {}
If you feel what you have is correct and it seems to bug out, you can temporarily disable it, using tsconfig.json
, until it get's fixed in a later release, but you must raise a bug on angular github (if you feel it's a bug).
{
"angularCompilerOptions": {
"extendedDiagnostics": {
"checks": {
"unusedStandaloneImports": "suppress"
}
}
}
}
The warning about unused imports in standalone components was introduced in Angular 19 (you can find more details in the official blog post here: https://blog.angular.dev/meet-angular-v19-7b29dfd05b84).
It seems that you've updated the "Angular Language Service" plugin in VS Code to version 19, but you haven't yet upgraded Angular itself in your package.json.
As a result, you're seeing the warning in VS Code, but when you try to build or serve your app, you encounter the following error: TS-994005: Angular compiler option "extendedDiagnostics.checks" has an unknown check: "unusedStandaloneImports."
To resolve this, you should update your Angular version to v19 in your package.json. This will allow the compiler to recognize the newly added extended diagnostics check for unused standalone imports. Once you've made this update, the TS-994005 error should disappear, and you can also suppress the check in your angularCompilerOptions
as needed.
angular language service
plugin, maybe that resolves it – Naren Murali Commented Nov 19, 2024 at 11:17