Tagged template strings in ES3/ES5

In TypeScript 1.4, we added support for template strings for all targets, and tagged templates for just ES6. Thanks to some considerable work done by @ivogabe, we bridged the gap for for tagged templates in ES3 and ES5.

When targeting ES3/ES5, the following code

  1. function oddRawStrings(strs: TemplateStringsArray, n1, n2) {
  2. return strs.raw.filter((raw, index) => index % 2 === 1);
  3. }
  4. oddRawStrings `Hello \n${123} \t ${456}\n world`

will be emitted as

  1. function oddRawStrings(strs, n1, n2) {
  2. return strs.raw.filter(function (raw, index) {
  3. return index % 2 === 1;
  4. });
  5. }
  6. (_a = ["Hello \n", " \t ", "\n world"], _a.raw = ["Hello \\n", " \\t ", "\\n world"], oddRawStrings(_a, 123, 456));
  7. var _a;