Skip to content

3.9.1-rc regression: Unable to specify rawText when programmatically creating tagged template literals #38485

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
petebacondarwin opened this issue May 11, 2020 · 4 comments · Fixed by #38500
Assignees
Labels
API Relates to the public API for TypeScript Bug A bug in TypeScript

Comments

@petebacondarwin
Copy link
Contributor

petebacondarwin commented May 11, 2020

TypeScript Version: 3.9.1-rc
Search Terms: tagged template literal rawText raw ES5

Code

The problem occurs when synthesising tagged template literals programmatically, and then trying to render them in ES5.

The API provides a method for specifying the "raw" parts of the template:

const template = ts.createNoSubstitutionTemplateLiteral('text', 'text');

But due to this regression this raw value is no longer being used.
An empty string is there, instead.

Here is a link to a reproduction: https://github.com/petebacondarwin/ts-3.9-rawtext-bug

Expected behavior:

$localize(__makeTemplateObject(["text"], ["text"]));

Actual behavior:

$localize(__makeTemplateObject(["text"], [""]));

Playground Link:
It is not possible to provide a Playground link because it only occurs when programmatically creating a tagged template literal AST node.

See the reproduction at https://github.com/petebacondarwin/ts-3.9-rawtext-bug

Related Issues:

This is a regression due to this commit: 70399e1#r39098346

@DanielRosenwasser DanielRosenwasser added API Relates to the public API for TypeScript Bug A bug in TypeScript labels May 12, 2020
@IgorMinar
Copy link

Hi ya'all!

This issue is currently blocking Angular from upgrading our ecosystem to TS3.9. We are exploring a workaround in case you can't fix this quickly, but we'd prefer a proper fix upstream.

Thank you!

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented May 12, 2020

Gotcha. We're planning a patch release later this month. If we could get something in the nightly and have something published at latest in ~2 weeks' time, would that be acceptable?

@IgorMinar
Copy link

That would work if that's the best you can do. We are working towards cutting Angular v10-rc.0 next Wednesday, so we'll keep on pursuing our workaround for rc.0. Thanks!

petebacondarwin added a commit to petebacondarwin/angular that referenced this issue May 12, 2020
…messages

In some versions of TypeScript, the transformation of synthetic
`$localize` tagged template literals is broken.
See microsoft/TypeScript#38485

We now compute what the expected final output target of the
compilation will be so that we can generate ES5 compliant
`$localize` calls instead of relying upon TS to do the downleveling
for us.

This is a workaround for the TS compiler bug, which could be removed
when this is fixed. But since it only affects ES5 targeted compilations,
which is now not the norm, it has limited impact on the majority of
Angular projects. So this fix can probably be left in indefinitely.
petebacondarwin added a commit to petebacondarwin/angular that referenced this issue May 12, 2020
…messages

In some versions of TypeScript, the transformation of synthetic
`$localize` tagged template literals is broken.
See microsoft/TypeScript#38485

We now compute what the expected final output target of the
compilation will be so that we can generate ES5 compliant
`$localize` calls instead of relying upon TS to do the downleveling
for us.

This is a workaround for the TS compiler bug, which could be removed
when this is fixed. But since it only affects ES5 targeted compilations,
which is now not the norm, it has limited impact on the majority of
Angular projects. So this fix can probably be left in indefinitely.
IgorMinar pushed a commit to petebacondarwin/angular that referenced this issue May 14, 2020
…messages

In some versions of TypeScript, the transformation of synthetic
`$localize` tagged template literals is broken.
See microsoft/TypeScript#38485

We now compute what the expected final output target of the
compilation will be so that we can generate ES5 compliant
`$localize` calls instead of relying upon TS to do the downleveling
for us.

This is a workaround for the TS compiler bug, which could be removed
when this is fixed. But since it only affects ES5 targeted compilations,
which is now not the norm, it has limited impact on the majority of
Angular projects. So this fix can probably be left in indefinitely.
kara pushed a commit to angular/angular that referenced this issue May 14, 2020
…messages (#36989)

In some versions of TypeScript, the transformation of synthetic
`$localize` tagged template literals is broken.
See microsoft/TypeScript#38485

We now compute what the expected final output target of the
compilation will be so that we can generate ES5 compliant
`$localize` calls instead of relying upon TS to do the downleveling
for us.

This is a workaround for the TS compiler bug, which could be removed
when this is fixed. But since it only affects ES5 targeted compilations,
which is now not the norm, it has limited impact on the majority of
Angular projects. So this fix can probably be left in indefinitely.

PR Close #36989
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented May 19, 2020

3.9.3 should be published with a fix.

profanis pushed a commit to profanis/angular that referenced this issue Sep 5, 2020
…messages (angular#36989)

In some versions of TypeScript, the transformation of synthetic
`$localize` tagged template literals is broken.
See microsoft/TypeScript#38485

We now compute what the expected final output target of the
compilation will be so that we can generate ES5 compliant
`$localize` calls instead of relying upon TS to do the downleveling
for us.

This is a workaround for the TS compiler bug, which could be removed
when this is fixed. But since it only affects ES5 targeted compilations,
which is now not the norm, it has limited impact on the majority of
Angular projects. So this fix can probably be left in indefinitely.

PR Close angular#36989
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Relates to the public API for TypeScript Bug A bug in TypeScript
Projects
None yet
4 participants