Repository navigation
Description
Which @angular/* package(s) are relevant/related to the feature request?
language-service
Description
This issue was raised in the vscode-ng-language-service repo by @mr1008 ie #65511, however I think it would be implemented in the base language service which is in this repo.
Description copied from #65511,
🚀 feature request
Description
Currently there is no way of marking components as deprecated. It would be cool if template editor supported standard way how deprecated code should be marked in TS/JS, using JSDoc @deprecated feature. This would help working in enterprise grade environment when there are multiple components and some of these should no longer be used. Currently it is very easy to forget/overlook such usage. Displaying it somehow in editor in straightforward way would help a lot.
Feature Type
Display somehow that component is deprecated.
Describe the solution you'd like
I believe the standard way of displaying would be fine, similar way as vscode does for TS/JS code. Currently WebStorm supports it and it looks like in the screenshot:
It supports standard way of marking elements as deprecated using JSDoc @deprecated feature. For example:
/**
- @deprecated DO NOT USE THIS TABLE.
*/
@component({
selector: 'app-table-old',
templateUrl: './old-table.component.html',
styleUrls: ['./old-table.component.scss']
})
FYI @Mr1008
Proposed solution
This could be implemented as a rule that provides diagnostics with deprecated tags that are then shown in the IDE, similar as happens in Typescript files.
Alternatives considered
No alternatives in VS Code.
The functionality seems to be available in Webstorm, sounds like they have a forked or extended version of the language service. It would be good to have this in the base language service so more IDEs can have this functionality.
Activity
eneajaho commentedon Jan 3, 2025
Just to note it down, when using standalone components it will show up in the imports array as deprecated.
eliasm307 commentedon Jan 3, 2025
@eneajaho
Yes that's in typescript files, as mentioned there's no issue there, but if just looking at the component template (eg in a different file) it's not clear what is deprecated, so devs could possibly keep using deprecated things/APIs without realising
eneajaho commentedon Jan 15, 2025
#59524
Looks like a fix is coming.
atscott commentedon Jan 15, 2025
Not quite. This would need to be done by providing semantic tokens, following this guide https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide.
One quick idea would be to get the semantic tokens for the type check block from the TS language service, filter down to the deprecated ones, and then map those back to their template locations.
eliasm307 commentedon Jan 15, 2025
@atscott from the investigation I did, I think also providing diagnostics would work, as you can add a diagnostic tag which produces the strike through effect, atleast on vs code.
Benefit of doing it as a diagnostic is that they are created and pushed from the base language service, which means this would apply to any lsp editors that use the language service
Also, regarding the comment about type check blocks, sounds like that would be specific to the js like aspects of templates, which would be useful, but wouldn't cover the entire template eg pipes, directives, components/elements etc which was the main motivation for the issue
feat(language-service): support to report the deprecated API in the t…
ivanwonder commentedon Jun 14, 2025
I agree to provide diagnostics for the deprecated information. I try using TCB. The challenging part is that the component class is used as a type, but there is no position map information for it.
atscott commentedon Jun 14, 2025
The place screenshot points to wouldn’t have a mapping to a template location because the constructor definition could be used in several places in the template. Its usage does have the source map comment below (var _t2).
ivanwonder commentedon Jun 15, 2025
Yes, but the deprecated range the ts reports is for the constructor definition, need to find a way to link it to the _t2.
feat(language-service): support to report the deprecated API in the t…
feat(language-service): support to report the deprecated API in the t…
feat(language-service): support to report the deprecated API in the t…
feat(language-service): support to report the deprecated API in the t…
feat(language-service): support to report the deprecated API in the t…
feat(language-service): support to report the deprecated API in the t…
angular-automatic-lock-bot commentedon Aug 14, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.