Skip to content

Downlevel TemplateStringsArray for tagged templates should be frozen #51789

Open
@rbuckton

Description

@rbuckton

Bug Report

The TemplateStringsArray we emit for tagged templates (as well as its raw property) should be frozen when we emit to --target ES5, to match the ES2015 specification. Without this change, developers could run into issues with a spec-compliant String.dedent polyfill. This was first reported here: tc39/proposal-string-dedent#75 (comment)

🔎 Search Terms

tagged template array frozen TemplateStringsArray

⏯ Playground Link

Playground link with relevant code

💻 Code

const f = (ar: TemplateStringsArray, ...args) => ar;
const x = f`a${1}b`
console.log(Object.isFrozen(x));
console.log(Object.isFrozen(x.raw));

🙁 Actual behavior

Neither the TemplateStringsArray nor its raw property are frozen.

🙂 Expected behavior

Both the TemplateStringsArray and its raw property should be frozen.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptES6Relates to the ES6 Spec

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions