coerce template literal expressions to strings - fixes #1065
This commit is contained in:
parent
c12cfe3ed0
commit
0ee230d13c
@ -1,9 +1,17 @@
|
||||
import * as t from "../../../types";
|
||||
|
||||
var buildBinaryExpression = function (left, right) {
|
||||
return t.binaryExpression("+", left, right);
|
||||
return t.binaryExpression("+", coerce(left), coerce(right));
|
||||
};
|
||||
|
||||
function coerce(node) {
|
||||
if (t.isLiteral(node) && typeof node.value === "string") {
|
||||
return node;
|
||||
} else {
|
||||
return t.callExpression(t.identifier("String"), [node]);
|
||||
}
|
||||
}
|
||||
|
||||
export function check(node) {
|
||||
return t.isTemplateLiteral(node) || t.isTaggedTemplateExpression(node);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user