Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codefix: convert const to let #22473

Closed
jwbay opened this issue Mar 11, 2018 · 12 comments · Fixed by #33157
Closed

Codefix: convert const to let #22473

jwbay opened this issue Mar 11, 2018 · 12 comments · Fixed by #33157
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@jwbay
Copy link
Contributor

jwbay commented Mar 11, 2018

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

@mhegazy mhegazy added Suggestion An idea for TypeScript Help Wanted You can do this Good First Issue Well scoped, documented and has the green light Domain: Quick Fixes Editor-provided fixes, often called code actions. labels Mar 30, 2018
@mhegazy mhegazy added this to the Community milestone Mar 30, 2018
@MagWeaver
Copy link

Can I take this one?

@DanielRosenwasser
Copy link
Member

Go for it!

@RubenMateus
Copy link

@MagWeaver any news from this?

@Fatehsandhu
Copy link

@DanielRosenwasser Can I please take over if it's possible?
Thanks

@mhegazy
Copy link
Contributor

mhegazy commented Jun 8, 2018

Go for it.

@Fatehsandhu
Copy link

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

@mhegazy
Copy link
Contributor

mhegazy commented Jun 19, 2018

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.

@muradkhan101
Copy link

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

@muradkhan101
Copy link

Hey @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!

@suhailsinghbains
Copy link

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

@muradkhan101
Copy link

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

@suhailsinghbains
Copy link

Sure @muradkhan101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
9 participants