Skip to content

Codefix: convert const to let  #22473

Description

@jwbay

TypeScript Version: 2.8.0-dev.20180308

Search Terms:
const let codefix

Code

const x = 42;

// lots of code

x/*1*/ = 75;

Expected behavior:
Error with codefix offered at 1 to convert the declaration from const to let

Actual behavior:
Just an error, no codefix

Related Issues:
The exact opposite of #13133

Activity

  1. added this to the milestone on Mar 30, 2018
  2. MagWeaver commented on Apr 3, 2018

    @MagWeaver

    Can I take this one?

  3. DanielRosenwasser commented on Apr 3, 2018

    @DanielRosenwasser
    Member

    Go for it!

  4. RubenMateus commented on Apr 8, 2018

    @RubenMateus

    Chris Weaver (@MagWeaver) any news from this?

  5. Fatehsandhu commented on Jun 8, 2018

    @Fatehsandhu

    Daniel Rosenwasser (@DanielRosenwasser) Can I please take over if it's possible?
    Thanks

  6. mhegazy commented on Jun 8, 2018

    @mhegazy
    Contributor

    Go for it.

  7. Fatehsandhu commented on Jun 15, 2018

    @Fatehsandhu

    Mohamed Hegazy (@mhegazy) Can I please get some help getting started? Which files should I be looking at?
    Thanks

  8. mhegazy commented on Jun 19, 2018

    @mhegazy
    Contributor

    Quick fixes are attached to diagnostics. in this case TS Error 2540: Cannot assign to 'x' because it is a constant or a read-only property.

    You can take a look at https://github.com/Microsoft/TypeScript/blob/master/src/services/codefixes/fixAwaitInSyncFunction.ts and https://github.com/Microsoft/TypeScript/blob/master/src/services/codefixes/fixSpelling.ts for a guide to how a quick fix can be implemented.

    Also you will need to add handling for the readonly property case, where the readonly modifier would be removed.

  9. muradkhan101 commented on Oct 2, 2018

    @muradkhan101

    Singh Sandhu (@Fatehsandhu) Still working on this? If not I'd like to take a shot at it :)

  10. muradkhan101 commented on Oct 3, 2018

    @muradkhan101

    Hey Mohamed Hegazy (@mhegazy), I have a potential fix for this here , but I couldn't find solid diagnostic messages to use and haven't figured out the readonly case yet though. Just wanted to check in with you to get some info about creating diagnostic messages and see if I'm on the right track here, thanks!

  11. suhailsinghbains commented on Oct 5, 2018

    @suhailsinghbains

    Hi,
    I'm new to open-source, can I please solve this issue?
    Thanks

  12. muradkhan101 commented on Oct 5, 2018

    @muradkhan101

    Suhail Singh Bains (@suhailsinghbains) I'm currently working on this one and am close to completing so your time may be better spent on another one. I'll let you know if anything changes however.

  13. suhailsinghbains commented on Oct 5, 2018

    @suhailsinghbains
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: LS: Quick FixesEditor-provided fixes, often called code actions.Good First IssueWell scoped, documented and has the green lightHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions