Skip to content

Change to template literals is breaking and undocumented #46844

New issue

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

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

Already on GitHub? # to your account

Closed
afrieder opened this issue Nov 17, 2021 · 4 comments
Closed

Change to template literals is breaking and undocumented #46844

afrieder opened this issue Nov 17, 2021 · 4 comments
Assignees
Labels
Breaking Change Would introduce errors in existing code Docs The issue relates to how you learn TypeScript

Comments

@afrieder
Copy link

afrieder commented Nov 17, 2021

Bug Report

πŸ”Ž Search Terms

Template literals, moment

πŸ•— Version & Regression Information

This began happening with the release of #45304 when targeting ES5.

⏯ Playground Link

Playground link

πŸ’» Code

import * as moment from 'moment';
window.alert(`Moment: ${moment()}`);

πŸ™ Actual behavior

In 4.5.2+, this compiles to "Moment: ".concat(moment()) which evaluates to "Moment: Wed Nov 17..."

πŸ™‚ Expected behavior

In previous versions of Typescript, this compiled to "Moment: " + moment() which resolves to "Moment: 1637.....

This change is breaking and was not documented in the release notes for 4.5.

Screen Shot 2021-11-17 at 3 54 13 PM

@RyanCavanaugh RyanCavanaugh added the Docs The issue relates to how you learn TypeScript label Nov 18, 2021
@RyanCavanaugh
Copy link
Member

We don't usually treat removing spec violations as breaking changes, but we can add it to the notes regardless.

@jcalz
Copy link
Contributor

jcalz commented Nov 18, 2021

Maybe we should add a --spacebarHeating compiler option.

Spacebar heating

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Nov 19, 2021

It's not now in the wiki and on the blog. Thanks!

@DanielRosenwasser DanielRosenwasser added the Breaking Change Would introduce errors in existing code label Nov 19, 2021
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.5.0 milestone Nov 19, 2021
@DanielRosenwasser
Copy link
Member

(@orta don't know if the website needs updates)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Breaking Change Would introduce errors in existing code Docs The issue relates to how you learn TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants