Skip to content

add codefix that rewrites var to let to const where appropriate #13133

Description

consider adding a codefix that transforms var to let to const by picking strictest declaration possible

Activity

  1. mhegazy commented on Dec 22, 2016

    @mhegazy
    Contributor

    We can do a refactoring for this. will have to think about cases where the var declaration is used outside the block where it is defined, we will need to hoist the declaration as well as change it to block-scoped declaration.

  2. zpdDG4gta8XKpMCd commented on Dec 22, 2016

    @zpdDG4gta8XKpMCd
    Author

    btw are refactorings even a thing that is somehow different from codefixes (i am asking because i see different tags are used to label similar issues)?

  3. DanielRosenwasser commented on Dec 22, 2016

    @DanielRosenwasser
    Member

    A code fix usually implies something is wrong - there's an error that can be amended. A refactoring implies rewriting working code in some manner. I think they both fall under the umbrella of "code actions".

    In general, I've been sloppy with the terminology with Paul van Brenk (@paulvanbrenk) correcting me every so often.

  4. mhegazy commented on Dec 22, 2016

    @mhegazy
    Contributor

    btw are refactorings even a thing that is somehow different from codefixes (i am asking because i see different tags are used to label similar issues)?

    Code Fix is tied to a diagnostic message, e.g. an error. If the error is shown, the editor shows you the option to "fix" it.

    Refactoring are more free form. you would right-click on a position and ask for possible refactorings.

    it is possible that you have the same change available as a Fix and as a refactoring.

  5. angelozerr commented on Apr 19, 2017

    @angelozerr

    tslint supports that. I have started to write a tslint plugin (for TypeScript 2.2.1) https://github.com/angelozerr/tslint-language-service . Here a demo with Eclipse but it works too with other IDE like VSCode:

    tslintnovardemo

  6. zpdDG4gta8XKpMCd commented on Apr 19, 2017

    @zpdDG4gta8XKpMCd
    Author

    why does it turn into let instead of const on the annimation?

  7. jessetrinity commented on Oct 21, 2020

    @jessetrinity
    Contributor

    ESLint already has a fix that does this - I don't think we should overlap.

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions