vscode-ng-language-service: The LS does not recognise components as being standalone
🐞 bug report
Description
Since Angular 19, components are standalone by default. However, the LS does not seems to take that into account. I’ve migrated my Angular app to Angular 19 so now all my components does not have anymore the standalone: true line but this cause errors to appears in every template and in every imports: [] because the LS does not consider my components to be standalone.
ps: I don’t use VSCode but I use Neovim.
Bug Type
What does this bug affect
- Angular Language Service VSCode extension
- Angular Language Service server
Reproduction
Steps to reproduce the behavior:
- Create a new Angular project
- Migrate the project to Angular 19
- See the error in app.component.ts saying that ‘imports’ is only valid on a component that is standalone.
Expected behavior
No error should appear.
Screenshots
🌍 Your Environment
Angular Version:
Angular CLI: 19.0.0
Node: 20.14.0
Package Manager: npm 10.9.0
OS: darwin arm64
Angular: 19.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1900.0
@angular-devkit/build-angular 19.0.0
@angular-devkit/core 19.0.0
@angular-devkit/schematics 19.0.0
@schematics/angular 19.0.0
rxjs 7.8.1
typescript 5.5.4
zone.js 0.15.0
Extension Version:
v19.0.2
Operating System:
macOS Sequoia : 15.0.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 16
- Comments: 27 (3 by maintainers)
@spock123 But you can do a global find & replace to change any:
@Component({To:
It takes like 30 seconds to do so.
The issue still persists in VS code with Angular Language Service 19.0.3
Same issue here.
a new version of
@angular/language-serverhas been published now, so everything should work fine now.I was also having the issue in neovim/mason. I tried uninstalling/reinstall/update, but that didn’t work. However, I found a temporary solution. The problem was that the language service was set to a next/preview build, not the most recent build. The angular server was set to the latest version, but the angular service (a dependency of the server) was on an outdated version.
cd
~/.local/share/nvim/mason/packages/angular-language-server(or the windows equivalent) Open the package-lock.json folder. Scroll to the@angular/language-serversection and examine the dependencies. Mine showed that@angular/language-servicewas set to 19.0.0-next.6It should be v19.0.1. (note that the latest version of the language server is 19.0.2, but the latest of the service is 19.0.1).
Change the version of the dependencies to be v19.0.1.
Scroll down to the language-service section. Change its version and URL to be the 19.0.1. Remove the integrity check if one is listed. I don’t know how to get the new integrity check, but if you know how to locate that then you could replace it.
Finally, run
npm iEverything is working now, but I’m guessing that a package update by mason would break it. I would like an easier fix than this, but this was enough for the moment.
Did anybody find any workarounds?
Encountering the same issue in Neovim as well (also using Mason).
I am experiencing this issue as well after updating my Nx monorepo to v19. VSCode extension version 19.0.2.
this has caused issues with projects using a version older than Angular 19, now. It incorrectly detects which angular is being used in the project and tells you that your components are standalone when they’re not. Now I need to explicitly add
standalone: falseto all of my components to remove errors that are not actually errors.We are getting the same issue and uninstalling does not fix the problem … so I just set standalone: true as workaround. Not ideal but better than getting the error.
We are using the vscode workspace feature.
@Ask-786 Beautiful, works here also! Wonderful! Cheers
@devversion For Neovim, the issue was related about how Mason manages the language server. The language server was set to use the language service
v19.0.0-next.6instead of thev19.0.1. So I guess we should open an issue in the Mason GitHub repo.For VSCode I don’t know since I’m not using it.
I don’t know what the state of this issue is, but:
@angular/language-serverdoes point to the latest Angular v19 version at this pointI suspect the issue most people are seeing here is that the VSCode extension picks one version of a e.g. monorepo. So, if you have e.g. Angular v18 somewhere in your project, the extension will use and treat the lack of
standalone: trueasstandalone: false— like it was the case with v18. Can someone with the problem verify this?The logic is not great, so this could serve as a tracking issue, but we should verify this is the problem first.