Skip to content

Tagged templates emit for ES3 & 5 #1590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ivogabe opened this issue Jan 4, 2015 · 0 comments
Closed

Tagged templates emit for ES3 & 5 #1590

ivogabe opened this issue Jan 4, 2015 · 0 comments
Labels
Fixed A PR has been merged for this issue In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@ivogabe
Copy link
Contributor

ivogabe commented Jan 4, 2015

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:

  1. Don't allow functions that take a TemplateStringsArray as first argument, only string[]
  2. Emit extra code (see below)
  3. If the function takes a string[] as first argument, emit as above, otherwise (also if first argument is any), 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)

@RyanCavanaugh RyanCavanaugh added In Discussion Not yet reached consensus Suggestion An idea for TypeScript labels Jan 8, 2015
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 1.5 milestone Jan 8, 2015
@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Mar 2, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants