decaffeinate-parser
Version:
A better AST for CoffeeScript, inspired by CoffeeScriptRedux.
22 lines (21 loc) • 986 B
JavaScript
;
exports.__esModule = true;
var nodes_1 = require("../nodes");
var getLocation_1 = require("../util/getLocation");
var mapAny_1 = require("./mapAny");
function mapTaggedTemplateCall(context, node) {
var _a = getLocation_1["default"](context, node), line = _a.line, column = _a.column, start = _a.start, end = _a.end, raw = _a.raw;
if (!node.variable) {
throw new Error('Expected tag in tagged template literal.');
}
var tag = mapAny_1["default"](context, node.variable);
if (node.args.length !== 1) {
throw new Error('Expected tagged template literal call to have exactly one argument.');
}
var template = mapAny_1["default"](context, node.args[0]);
if (!(template instanceof nodes_1.String)) {
throw new Error('Expected tagged template literal argument to be a string.');
}
return new nodes_1.TaggedTemplateLiteral(line, column, start, end, raw, tag, template);
}
exports["default"] = mapTaggedTemplateCall;