Repository navigation
add codefix that rewrites var to let to const where appropriate #13133
Description
Activity
We can do a refactoring for this. will have to think about cases where the
vardeclaration 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.- addedDomain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolSuggestionAn idea for TypeScriptAn idea for TypeScript
on Dec 22, 2016 zpdDG4gta8XKpMCd commented
on Dec 22, 2016 AuthorMore actionsbtw 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)?
DanielRosenwasser commented
on Dec 22, 2016 MemberMore actionsA 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.
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.
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:
zpdDG4gta8XKpMCd commented
on Apr 19, 2017 AuthorMore actionswhy does it turn into
letinstead ofconston the annimation?- addedExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancements
on Aug 13, 2018 - addedIn DiscussionNot yet reached consensusNot yet reached consensus
on Nov 6, 2018 - removedIn DiscussionNot yet reached consensusNot yet reached consensus
on Jul 29, 2019 jessetrinity commented
on Oct 21, 2020 ContributorMore actionsESLint already has a fix that does this - I don't think we should overlap.

consider adding a codefix that transforms
vartolettoconstby picking strictest declaration possible