Skip to content

Show deprecated template items in IDE #59343

Closed

Description

@eliasm307

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: image

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

  1. added
    area: language-service
    on Jan 1, 2025
  2. added this to the needsTriage milestone on Jan 1, 2025
  3. eneajaho commented on Jan 3, 2025

    @eneajaho
    Contributor

    Just to note it down, when using standalone components it will show up in the imports array as deprecated.

    Image

  4. eliasm307 commented on Jan 3, 2025

    @eliasm307
    Author

    @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

  5. eneajaho commented on Jan 15, 2025

    @eneajaho
    Contributor

    #59524

    Looks like a fix is coming.

  6. atscott commented on Jan 15, 2025

    @atscott
    Contributor

    #59524

    Looks like a fix is coming

    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.

  7. eliasm307 commented on Jan 15, 2025

    @eliasm307
    Author

    @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

  8. ivanwonder commented on Jun 14, 2025

    @ivanwonder
    Contributor

    @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.

    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.

    Image
  9. atscott commented on Jun 14, 2025

    @atscott
    Contributor

    but there is no position map information for it.

    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).

  10. ivanwonder commented on Jun 15, 2025

    @ivanwonder
    Contributor

    but there is no position map information for it.

    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).

    Yes, but the deprecated range the ts reports is for the constructor definition, need to find a way to link it to the _t2.

  11. angular-automatic-lock-bot commented on Aug 14, 2025

    @angular-automatic-lock-bot

    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.

  12. locked and limited conversation to collaborators on Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: language-service

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions