-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
Priority: HighSpec: Template Literal RevisionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Milestone
Description
The Template Literals Revision proposal reached Stage 3 in July, but is not yet implemented.
Input Code
Example derived from the proposal linked above.
function tag(strs) {
assert(strs[0] === undefined);
assert(strs.raw[0] === "\\unicode and \\u{55}");
}
tag`\unicode and \u{55}`;Expected Behavior
The above code should execute without throwing any error.
Current Behavior
An error is currently thrown by Babylon:
repl: Bad character escape sequence (5:6)
3 | assert(strs.raw[0] === "\\unicode and \\u{55}");
4 | }
> 5 | tag`\unicode and \u{55}`;
|
Possible Solution
First step would of course be adding support for it in Babylon.
Currently, the babel-plugin-transform-es2015-template-literals plugin transforms
tag`ab\\c`;to
var _templateObject = _taggedTemplateLiteral(["ab\\c"], ["ab\\\\c"]);
function _taggedTemplateLiteral(strings, raw) {
return Object.freeze(Object.defineProperties(strings, {
raw: {
value: Object.freeze(raw)
}
}));
}
tag(_templateObject);To support this new syntax it could just convert
tag`\unicode and \u{55}`;to
var _templateObject = _taggedTemplateLiteral([], ["\\unicode and \\u{55}"]);
function _taggedTemplateLiteral(strings, raw) {
return Object.freeze(Object.defineProperties(strings, {
raw: {
value: Object.freeze(raw)
}
}));
}
tag(_templateObject);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Priority: HighSpec: Template Literal RevisionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue