-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
Currently tagged templates aren't supported when targeting ES3 or ES5. Tagged templates can be (partially) emitted like this:
foo(["A ", " B ", " C"], 1, 2);
The only difference with ES6 is (if I'm not mistaken) that the raw
property on the first argument is missing. I think there are 3 solutions for this:
- Don't allow functions that take a
TemplateStringsArray
as first argument, onlystring[]
- Emit extra code (see below)
- If the function takes a
string[]
as first argument, emit as above, otherwise (also if first argument isany
), emit as below.
Alternative javascript would be:
var __template;
foo((__template = ["A ", " B ", " C"], __template.raw = ["A ", " B ", " C"], __template), 1, 2);
I'd vote for 1, since the .raw
property won't be used in most cases.
I've implemented basic functionality in #1589 (without a solution for the .raw
property)
Metadata
Metadata
Assignees
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript