decaffeinate-parser
Version:
A better AST for CoffeeScript, inspired by CoffeeScriptRedux.
19 lines (18 loc) • 874 B
JavaScript
import { String, TaggedTemplateLiteral } from '../nodes';
import getLocation from '../util/getLocation';
import mapAny from './mapAny';
export default function mapTaggedTemplateCall(context, node) {
var _a = getLocation(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(context, node.variable);
if (node.args.length !== 1) {
throw new Error('Expected tagged template literal call to have exactly one argument.');
}
var template = mapAny(context, node.args[0]);
if (!(template instanceof String)) {
throw new Error('Expected tagged template literal argument to be a string.');
}
return new TaggedTemplateLiteral(line, column, start, end, raw, tag, template);
}