sublimelsp / LSP-typescript

TypeScript, JavaScript support for Sublime LSP plugin
MIT License
135 stars 11 forks source link

"Code action: Convert 'const' to 'let'" breaks in for statement #67

Closed saneef closed 3 years ago

saneef commented 3 years ago

The const to let conversion in for statement creates wrong code:

Before:

for (const i: number = 0; i < 20; i++) {
    console.log(i);
}

After:

letconst i: number = 0; i < 20; i++) {
    console.log(i);
}

Wrong code action with for loop

rchl commented 3 years ago

This is an issue in the Typescript itself. You can reproduce it here also:

https://www.typescriptlang.org/play?#code/LAKAZg9gTgBAFAYwgOwM4BcYEsBcNkCuAtgEYCmsAvDAAwDc2MAPDAEz3YDUnAlDAN6gYwmEjQQANmQB0EiAHM4WHqAC+oIA

I'd suggest reporting that at https://github.com/microsoft/TypeScript/issues, if it's not already.