Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
constant-folding: Handle simple template strings in .join()s
  • Loading branch information
goto-bus-stop committed Aug 15, 2017
commit f45656b260e06a61fa1459c712a08487e8a703ad
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe("constant-folding-plugin", () => {
[null, 1].join("/");
[/xyz/im, true].join("abc");
[\`a\${xyz}\`].join("1");
[\`a\`, \`c\`].join('b');

[1, 2, 3].length;
[1, 2, 3][1];
Expand Down Expand Up @@ -140,6 +141,7 @@ describe("constant-folding-plugin", () => {
"/1";
"/xyz/imabctrue";
[\`a\${xyz}\`].join("1");
"abc";

3;
2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ module.exports = ({ types: t }) => {
) {
return el.value;
}
if (t.isTemplateLiteral(el) && el.expressions.length === 0) {
return el.quasis[0].value.cooked;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
bad = true;
return;
})
Expand Down