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 Good First Issue Help Wanted Suggestion

Comments

@jwbay
Copy link

@jwbay 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 Help Wanted Good First Issue Domain: Quick Fixes labels Mar 30, 2018
@mhegazy mhegazy added this to the Community milestone Mar 30, 2018
@MagWeaver
Copy link

@MagWeaver MagWeaver commented Apr 3, 2018

Can I take this one?

@DanielRosenwasser
Copy link

@DanielRosenwasser DanielRosenwasser commented Apr 3, 2018

Go for it!

@RubenMateus
Copy link

@RubenMateus RubenMateus commented Apr 8, 2018

@MagWeaver any news from this?

@Fatehsandhu
Copy link

@Fatehsandhu Fatehsandhu commented Jun 8, 2018

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

@mhegazy
Copy link

@mhegazy mhegazy commented Jun 8, 2018

Go for it.

@Fatehsandhu
Copy link

@Fatehsandhu Fatehsandhu commented Jun 15, 2018

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

@mhegazy
Copy link

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

@muradkhan101 muradkhan101 commented Oct 2, 2018

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

@muradkhan101
Copy link

@muradkhan101 muradkhan101 commented Oct 3, 2018

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

@suhailsinghbains suhailsinghbains commented Oct 5, 2018

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

@muradkhan101
Copy link

@muradkhan101 muradkhan101 commented Oct 5, 2018

@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

@suhailsinghbains suhailsinghbains commented Oct 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Quick Fixes Good First Issue Help Wanted Suggestion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants