You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Don't offer Convert to template string refactoring for simple strings #36784
So clearly this is silly because there are certain positions where a template string isn't valid - I think it'd probably be okay to disable this for simple strings, but we should revisit whether we want to enable it for all strings and disable it for nonsensical positions like
I'd prefer to only see this refactoring when the cursor on a string concatenation expression
Also, we probably want to fix this for 3.8 (either for the final release or in a recovery build) as it is rather annoying to have the lightbulb show up for every string
Just as a contrasting opinion, I actually find this behavior useful (in cases where template strings would be legal). After using TS/JS for years, my muscle memory now defaults to ${...} rather than + to template values into strings, and it's nice to be able to quickly convert the string in question to a template string in cases where it isn't already.
That said Daniel Rosenwasser (@DanielRosenwasser), another potential approach could be to make the suggestion if the string in question contains ${. Just a thought. 🙂
Reacted by Neale Upstone, Nicolas Carlo, Tobias Stupperich and Oliver Joseph Ash
For the context, I'm the author of a VS Code extension that provides JS & TS refactorings. We used to provide "Convert to Template Literal". We removed it since it's now handled by the editor, through TypeScript.
However, it was very valid (and convenient) to switch from:
consta="I have some apples";
to
consta=`I have some apples`;
To start inserting variables inside.
I understand this was dropped as a side-effect of a bug fix. I think what we really want to avoid is proposing the refactoring for invalid things like imports. I implemented that kind of check in my extension indeed.
Activity
DanielRosenwasser commentedon Feb 13, 2020
So clearly this is silly because there are certain positions where a template string isn't valid - I think it'd probably be okay to disable this for simple strings, but we should revisit whether we want to enable it for all strings and disable it for nonsensical positions like
mjbvz commentedon Feb 13, 2020
I'd prefer to only see this refactoring when the cursor on a string concatenation expression
Also, we probably want to fix this for 3.8 (either for the final release or in a recovery build) as it is rather annoying to have the lightbulb show up for every string
treybrisbane commentedon Feb 15, 2020
Just as a contrasting opinion, I actually find this behavior useful (in cases where template strings would be legal). After using TS/JS for years, my muscle memory now defaults to
${...}rather than+to template values into strings, and it's nice to be able to quickly convert the string in question to a template string in cases where it isn't already.That said Daniel Rosenwasser (@DanielRosenwasser), another potential approach could be to make the suggestion if the string in question contains
${. Just a thought. 🙂nicoespeon commentedon Apr 9, 2020
Hey there 👋
A quick heads-up to support Trey Brisbane (@treybrisbane) point of view.
For the context, I'm the author of a VS Code extension that provides JS & TS refactorings. We used to provide "Convert to Template Literal". We removed it since it's now handled by the editor, through TypeScript.
However, it was very valid (and convenient) to switch from:
to
To start inserting variables inside.
I understand this was dropped as a side-effect of a bug fix. I think what we really want to avoid is proposing the refactoring for invalid things like imports. I implemented that kind of check in my extension indeed.
You can check nicoespeon/abracadabra#94 for more context on this.
If you need more details, I'd be happy to help 😄
Thank you!