-
Notifications
You must be signed in to change notification settings - Fork 10
Template strings #2
Comments
So the problem with this one is that coffeescript has multiple compile steps. Some of the compilation (like the compiling of strings) is actually done inside the lexer -_-. By the time coffeescript gives me the AST, the string There are two solutions to this issue: 1 - Monkey patching coffee script (which would mean a massive extra file). Any thoughts @flying-sheep @eventualbuddha ? |
or 4 - working together with @jashkenas to sort this out. we’d reopen jashkenas/coffeescript#2365 for single line comments, and help fixing jashkenas/coffeescript#4192 |
Another idea: Automatically output ES6 template strings instead of string concatenation, regardless of whether the CoffeeScript input was |
sure! why didn’t i think of this? 😃 |
I would vote for detecting string additions that actually were originally string interpolations. This can be done by looking at the unrewritten tokens for the node (decaffeinate-parser does that). I'm afk so can't provide details now. Also, esnext will automatically turn string additions into interpolations as you suggest. You don't want to do it with |
|
True… so you'd just have to be careful that you don't do it when two non-strings could be added, like |
well, that could be translated to `${a + b}c` algo idea:
a + b + "c" + d + e + "f" + g is left-associative so the |
Honestly I'd like to preserve the code authors intention as much as possible. I thought about turning all string concatenation into template strings but I'm not convinced that it better serves peoples use-case or simplifies this problem. The purpose of decaf is first and foremost not a code-improvement tool but a code-translation tool. I'd like to stick with the original intent here. |
sure. now that we can change the CS AST upstream, that’s also no longer a problem |
Missing feature!
Template strings like this:
should transpile to
The text was updated successfully, but these errors were encountered: