GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — @‌deprecated JSDoc tag · Issue #390 · microsoft/TypeScript

@‌deprecated JSDoc tag #390

New issue
Copy link
New issue
Copy link
Closed
#38523
Closed
@‌deprecated JSDoc tag#390
#38523
Copy link
Labels
Domain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generationNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript

Description

@DickvdBrink
Dick van den Brink (DickvdBrink)
opened on Aug 7, 2014
Issue body actions

It would be cool to annotate a method or property with a deprecated attribute

Proposal

If a warning could be issued when using a deprecated method or property it is easier to upgrade to a newer library version (only when the definitions are up to date of course)

Syntax: Same as JSDoc, a simple comment

/**
 * @deprecated Use other method
 */
public foo() {
}

If supported in .d.ts files, this would really help with upgrading to a newer version.

Reacted by Clay Anderson, Dibran Mulder, Bond, Alex, Igor Minin, Rokas Brazdžionis, Boris Aranovič, binarious, Churakov Andrey, Markus Lindenmann and 279 more
Reacted by _al.pt_old, Michael Trouw, Ken, Rémi Chanaud, The web walker, limichange and Roger Padilla
Reacted by Ken, The web walker, limichange, Ghislain B., Roger Padilla, Michael Trouw and poseidonCore
Reacted by Ken, The web walker, limichange, Roger Padilla and Michael Trouw

Activity

Next
  1. Ryan Cavanaugh (RyanCavanaugh)
    added
    Needs Proposal
    on Aug 7, 2014
  2. RyanCavanaugh commented on Aug 7, 2014

    @RyanCavanaugh
    Ryan Cavanaugh (RyanCavanaugh)
    on Aug 7, 2014
    Member
    More actions

    How would this flow through the type system?

    interface X {
        /*
         * @deprecated Use DoOtherThing instead
         */
        doThing(): void;
    }
    
    interface Y {
        /*
         * Still supported
         */
        doThing(): void;
    }
    
    class Z implements X, Y {
        doThing() {}
    }
    
    var g = new Z();
    g.doThing(); // OK? Not OK?

    Presumably you'd be able to mark a single overload (but not others) as deprecated; would referencing (but not calling) a function with a deprecated overload be an error?

    Reacted by lilezek, HermannGruber, ExE Boss, Moritz Mahringer, Mikhail Udalov, stefnotch, fregante, Luke, Ilya V., Luis Custodio and 3 more
    Reacted by Amit Beckenstein
  3. DickvdBrink commented on Aug 7, 2014

    @DickvdBrink
    Dick van den Brink (DickvdBrink)
    on Aug 7, 2014
    ContributorAuthor
    More actions

    Hmz, tricky question.. didn't thought about this one actually.

    Maybe it is only an error in this case when calling it like this:

    var x: X = new Z();
    x.doThing() // it selected to @deprecated methode so error
    
    var y: Y = new Z();
    x.doThing() // still supporter, no error

    Not really sure though, feels a bit error prone...

    Reacted by OldStarchy
    Reacted by 浊酒
  4. JustinBeckwith commented on Jan 6, 2015

    @JustinBeckwith
    Justin Beckwith (JustinBeckwith)
    on Jan 6, 2015
    More actions

    C# will allow what you've written above, because it does not react to [Obsolete] attributes on interfaces - only base class implementations. Given the lack of multiple inheritence, this isn't really an issue. Here's how it's handled in C#:

    class Program
        {
            static void Main(string[] args)
            {
                var x = new Zoo();
    
                // doThing is allowed, even though it is obsolete on interface X
                x.doThing();
    
                // doStuff is not allowed. It is not obsolete on the interface, but is obsolete on the base class. 
                x.doStuff();
                Console.Read();
    
            }
        }
    
        interface X
        {
            /// <summary>
            /// 
            /// </summary>
            [Obsolete("boo", true)]
            void doThing();
        }
    
        interface Y
        {
            void doThing();
            void doStuff();
        }
    
        class Zoo : ZooBase, X
        {
            public void doThing()
            {
                Console.WriteLine("boo");
            }
    
            [Obsolete]
            public override void doStuff()
            {
                Console.WriteLine("boo");
            }
        }
    
        abstract class ZooBase
        {
            [Obsolete("boo", true)]
            public abstract void doStuff();
        }
    Reacted by Steven, Florian Rappl, PeterGabriel2 and Shinigami
  5. mhegazy commented on Jan 12, 2015

    @mhegazy
    Mohamed Hegazy (mhegazy)
    on Jan 12, 2015
    Contributor
    More actions

    I think this is fair. the class provided a re-declaration of the method. if you were to use the interface directly you would get an error:

    var g = new Z();
    g.doThing(); // OK, this is the class definition of doThing()
    
    var e: X = new Z();
    e.doThing(); // Error, X.doThing() is deprecated.

    Now consider this:

    interface Person {
        name: string;
    
        /** @deprecated use birthDate instead */
        age?: number;
    
        birthDate?: Date;
    }
    
    declare function doStuff(p: Person): void;
    
    // should calling doStuff with age instead of birthDate be an error:
    
    doStuff({
        name: "Joe",
        age: 25          // Error?: Person.age is depreciated
    });

    if the answer is yes, then the above example should be an error on the extends clause, prohibiting the implementation of a depreciated method on the interface.

    it also means you can not depreciate a non-optional member of an interface, cause how else would you use it.

  6. louy commented on Nov 27, 2015

    @louy
    Louay Akkad (louy)
    on Nov 27, 2015
    More actions

    I believe this shouldn't cause an error but rather a warning.
    For the situation Ryan Cavanaugh (@RyanCavanaugh) mentioned, a function would only be deprecated if there doesn't exist any non-deprecated implementation.
    As for implementing an interface-deprecated method in a class, you should get a warning once in the class implementation, not each time you're calling the method.

    interface IX {
      @deprecated
      function doSomething(): void;
    }
    
    class X implements IX {
      function doSomething(): void; // Warning: IX.doSomething is deprecated
    
      @deprecated
      function doSomethingElse(): void;
    }
    
    const x = new X();
    x.doSomething(); // Ok...
    x.doSomethingElse(); // Warning: X.doSomethingElse is deprecated
    Reacted by csha, Anton Bessonov, Nikolas Bousios, Max and Joseph McMurray
  7. kitsonk commented on Nov 27, 2015

    @kitsonk
    Kitson Kelly (kitsonk)
    on Nov 27, 2015
    Contributor
    More actions

    That syntax collides with decorators. 😦

    Considering this hasn't seen any action in a long time, and now that the compiler parses and integrates JSDoc, it could in theory understand and warn on /* @depecrated */ JSDoc, but is there yet the concept of warning in TypeScript or does it still consider everything an error?

    Otherwise this should be the domain of something like tslint Adi Dahiya (@adidahiya), thoughts?

    Reacted by Felix Becker, Yawar Amin, csha, Lea Reimann and Tim Ritzer
  8. louy commented on Nov 27, 2015

    @louy
    Louay Akkad (louy)
    on Nov 27, 2015
    More actions

    Yeah I know. I didn't know that the complier considered JSDoc comments. I thought we might have a reserved keyword or something.
    I also think this is beyond the scope of tslint. Linting should be about coding style, not type checking.

    AFAIK TS has no concept of warnings. In my opinion however, it should. Similar to ESLint's error/warning concepts.

    Reacted by Gary Gozlan
    Reacted by Szymon
  9. kitsonk commented on Nov 27, 2015

    @kitsonk
    Kitson Kelly (kitsonk)
    on Nov 27, 2015
    Contributor
    More actions

    Linting should be about coding style, not type checking.

    I disagree... It should be about things deal with code quality, things that are syntactical errors. tslint and other linting tools do lots of quality checking, like unused variables, conditional assignments, switch statement drop through and defaults, etc.

    In fact we draw the defenition from the UNIX lint tool which:

    In computer programming, lint is a Unix utility that flags some suspicious and non-portable constructs (likely to be bugs) in C language source code; generically, lint or a linter is any tool that flags suspicious usage in software written in any computer language.

    Reacted by Felix Becker, Karol Mierzejewski, Junyoung/"Clare" Jang, ExE Boss, Szymon and Debajyoti Bhaumik
  10. louy commented on Nov 27, 2015

    @louy
    Louay Akkad (louy)
    on Nov 27, 2015
    More actions

    Kitson Kelly (@kitsonk) okay I'm convinced. I'll open a new issue in tslint's repo then.

  11. felixfbecker commented on Mar 27, 2016

    @felixfbecker
    Felix Becker (felixfbecker)
    on Mar 27, 2016
    Contributor
    More actions

    I also think this is something that does not need a language feature, but belongs to documentation (jsdoc) and can be checked by something like tslint.

    Reacted by AA, xdvarpunen, Florian Wendelborn, Devin Rhode and Henry Chan
    Reacted by ikokostya, mdcorriveau, Tanguy Krotoff, Haroen Viaene, Itrulia, Carlos Gomes Martinho, Christian d'Heureuse, Junyoung/"Clare" Jang, John Haugeland, stunaz and 14 more
  12. Leo Rudberg (LOZORD)
    added a commit that references this issue on Aug 20, 2016

    Fixes DefinitelyTyped#10684

    32b16f4
  13. Masahiro Wakame (vvakame)
    added a commit that references this issue on Sep 14, 2016

    Fixes #10684 (#10751)

    b73aaa3
  14. Masahiro Wakame (vvakame)
    added a commit that references this issue on Oct 25, 2016

    Added Seeded interface to Chance definition (#11919)

    7ee0485
  15. 19 remaining items

  16. Daniel Rosenwasser (DanielRosenwasser)
    changed the title [-]Deprecated attribute[/-] [+]@‌deprecated JSDoc Attribute[/+] on Apr 10, 2020
  17. Daniel Rosenwasser (DanielRosenwasser)
    changed the title [-]@‌deprecated JSDoc Attribute[/-] [+]@‌deprecated JSDoc tag[/+] on Apr 10, 2020
  18. Kingwl commented on May 13, 2020

    @Kingwl
    Wenlu Wang (Kingwl)
    on May 13, 2020
    Contributor
    More actions

    I'd like to work on this both ts and vscode side.

    Reacted by Donald Pipowitch, limichange, Denis Bendrikov, Joseph Kohlmann, Ghislain B., Glen, Anton Fedchenko and Ken
  19. luke-john commented on Jun 10, 2020

    @luke-john
    Luke John (luke-john)
    on Jun 10, 2020
    More actions

    It's unclear to me from this proposal whether deprecating an entry in a union would be supported.

    type Props = {
        value:
            | 'a'
            | 'one' 
            /** @deprecated */
            | 'value-one' 
    }

    If so great 👍. If not would it be possible to include that in this proposal or would it be better to create a separate proposal?

    Reacted by Holger Jeromin, Vincent Ricard, Daniel Knaust, Evan Jacobs, zhao5363, recordare, Demian Ferreiro, ExE Boss, Hays Clark, Karol Majewski and 9 more
  20. JasonHK commented on Jun 10, 2020

    @JasonHK
    Jason Kwok (JasonHK)
    on Jun 10, 2020
    More actions

    It's unclear to me from this proposal whether deprecating an entry in a union would be supported.

    type Props = {
        value:
            | 'a'
            | 'one' 
            /** @deprecated */
            | 'value-one' 
    }

    If so great 👍. If not would it be possible to include that in this proposal or would it be better to create a separate proposal?

    Luke John (@luke-john) I think union and insertion type members don't support TSDoc at all.

  21. luke-john commented on Jun 10, 2020

    @luke-john
    Luke John (luke-john)
    on Jun 10, 2020
    More actions

    You're correct that they don't support tsdoc style comments (seems to be a recent issue requesting that at #38106)

    However they do support typescript comments such as // @ts-ignore which this seems similar to (though instead of suppressing errors/warnings, it triggers them).

    https://www.typescriptlang.org/play/?ssl=6&ssc=17&pln=7&pc=26#code/C4TwDgpgBAYg9nAPAFQgZ2FCAPYEB2AJmlPgK4C2ARhAE4B8UAvFKhgFDuiRQAKtcMCRYBvdlAlQAbgEMANmQgAucZLUAfKAHIZW1WomatcfBC1R9BgPQAqG1AACwNAFoAlgHN8cWtBtXLDVgERC1ZBQgXEzN6dgBfTiA

    Reacted by Demian Ferreiro
  22. Nathan Shively-Sanders (sandersn)
    closed this as completedin #38523on Jun 19, 2020
  23. Daniel Rosenwasser (DanielRosenwasser)
    removed
    Domain: DecoratorsThe issue relates to the decorator syntaxThe issue relates to the decorator syntax
    on Jun 24, 2020
  24. ghiscoding commented on Sep 19, 2020

    @ghiscoding
    Ghislain B. (ghiscoding)
    on Sep 19, 2020
    More actions

    Since this is now a thing, it could be removed from Roadmap Future section

    Investigate Ambient, Deprecated, and Conditional decorators

    Reacted by Niklas Higi
  25. haysclark commented on Sep 24, 2020

    @haysclark
    Hays Clark (haysclark)
    on Sep 24, 2020
    More actions

    Since this is now a thing, it could be removed from Roadmap Future section

    Investigate Ambient, Deprecated, and Conditional decorators

    Before Deprecated is removed from the Roadmap, it would be great to learn more about the possibility of supporting deprecated Unions. IMHO, this is an extremely common User Case which Luke John (@luke-john) also mentioned above.

    e.g.

    /** @deprecated */
    type LegacySizes =
      | "sm"
      | "lg";
    export type ButtonSizes =
      | LegacySizes
      | "small"
      | "medium"
      | "large";
    
    export interface ButtonProps {
      size?: ButtonSizes;
    }
    Reacted by John Grishin, Celo Reis, Andrei Lozhkin, Jason Kwok, Mark McDermid, juanvargas, Gabriele Tomberli, Rob Wierzbowski, Thom Wheeler, Cameron Moon and 7 more
  26. devinrhode2 commented on Apr 14, 2021

    @devinrhode2
    Devin Rhode (devinrhode2)
    on Apr 14, 2021
    More actions

    Is this supported now? If so where are the docs for this? (Or can anyone share an example?)

  27. NateScarlet commented on Apr 14, 2021

    @NateScarlet
    NateScarlet (NateScarlet)
    on Apr 14, 2021
    More actions

    Devin Rhode (@devinrhode2)

    图片

    https://jsdoc.app/tags-deprecated.html

    Reacted by Davide Campello
    Reacted by Devin Rhode
  28. SebastianStehle commented on Jul 25, 2021

    @SebastianStehle
    Sebastian Stehle (SebastianStehle)
    on Jul 25, 2021
    More actions

    Is it possible to mark all deprecated warnings?

  29. HolgerJeromin commented on Aug 11, 2021

    @HolgerJeromin
    Holger Jeromin (HolgerJeromin)
    on Aug 11, 2021
    Contributor
    More actions

    Sebastian Stehle (@SebastianStehle) Perhaps you can use something like https://github.com/gund/eslint-plugin-deprecation

    Reacted by Nathan Shively-Sanders, Arti Villa and Chris Kuech
  30. xiaoxiangmoe commented on Feb 27, 2022

    @xiaoxiangmoe
    ZHAO Jin-Xiang (xiaoxiangmoe)
    on Feb 27, 2022
    Contributor
    More actions

    Also, we can use https://www.npmjs.com/package/eslint-plugin-sonar

    // .eslintrc.cjs
    {
      "plugins": ["sonar"],
      "rules": {
        "sonar/deprecation": 1
      }
    }
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

    Domain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generationNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.