Skip to content

Change to template literals is breaking and undocumentedΒ #46844

Closed
@afrieder

Description

@afrieder

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

Metadata

Metadata

Labels

Breaking ChangeWould introduce errors in existing codeDocsThe issue relates to how you learn TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions